52 lines
1.4 KiB
Python
Executable File
52 lines
1.4 KiB
Python
Executable File
from discord.ext import commands
|
|
import discord
|
|
import queue
|
|
import threading
|
|
|
|
import core_utils
|
|
import warframe
|
|
|
|
|
|
class Warframe(commands.Cog):
|
|
def __init__(self, bot):
|
|
self.bot: commands.Bot = bot
|
|
|
|
warframe = discord.SlashCommandGroup("warframe", "Warframe related commands")
|
|
|
|
async def get_all_mods(ctx: discord.AutocompleteContext):
|
|
threads = []
|
|
q = queue.Queue(maxsize=0)
|
|
for letter in [chr(i) for i in range(ord("a"), ord("z") + 1)]:
|
|
t = threading.Thread(target=warframe.query_wiki, args=(letter, q))
|
|
t.start()
|
|
threads.append(t)
|
|
|
|
# Block until all threads / queues are done working
|
|
q.join()
|
|
for x in threads:
|
|
x.join()
|
|
|
|
return sorted([item for sublist in list(q.queue) for item in sublist])
|
|
|
|
@warframe.command(
|
|
guild_ids=core_utils.my_guilds,
|
|
name="mod",
|
|
description="Query the warframe wiki for a mod",
|
|
)
|
|
async def get_warframe_mod(
|
|
self,
|
|
ctx: commands.Context,
|
|
mod: discord.Option(
|
|
str,
|
|
autocomplete=discord.utils.basic_autocomplete(get_all_mods),
|
|
description="The mod to look up",
|
|
),
|
|
):
|
|
await ctx.defer()
|
|
# embed = await star_citizen.get_ship(ship_name=ship)
|
|
await ctx.send_followup(f"you picked {mod}")
|
|
|
|
|
|
def setup(bot):
|
|
bot.add_cog(Warframe(bot))
|