dragon-bot/app/cogs/warframe.py
Luke R 547d4677c9
All checks were successful
Build and push / changes (push) Successful in 41s
Build and push / Lint-Python (push) Successful in 12s
Build and push / Build-and-Push-Docker (push) Successful in 1m53s
Build and push / sync-argocd-app (push) Successful in 9s
Adding trader reset command to the bot
2024-10-17 15:03:14 -07:00

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))