dragon-bot/app/cogs/warframe.py

57 lines
1.5 KiB
Python
Executable File

from bs4 import BeautifulSoup
from discord import option
from discord.ext import commands, tasks
import discord
import json
import os
import queue
import requests
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))