summary refs log tree commit diff stats
path: root/bot.py
blob: 3b7556588415d6a22e1cf2fe3002d5c0db4a2390 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import discord
from discord import Interaction, Intents, Embed
from discord.ext.commands import Bot, Context, when_mentioned
from dotenv import load_dotenv
from os import getenv
from sys import exit
from typing import Literal
import httpx
import nltk
import asyncio

load_dotenv()

if getenv('TOKEN') is None or getenv('OWNER_ID') is None:
    print('please set a TOKEN and OWNER_ID environment variable')
    exit(1)

class QBBBot(Bot):
    def __init__(self) -> None:
        super().__init__(command_prefix=when_mentioned, intents=Intents.default())

    async def setup_hook(self):
        await self.load_extension('cogs.tossup')
        await self.load_extension('cogs.solo')
        await self.load_extension('cogs.stats')
        await self.load_extension('jishaku')


bot = QBBBot()
bot.qb_categories = Literal['Literature', 'History', 'Science', 'Fine Arts', 'Religion', 'Mythology', 'Philosophy',
                            'Social Science', 'Current Events', 'Geography', 'Other Academic', 'Trash']


@bot.command()
async def sync(ctx: Context):
    if str(ctx.author.id) == getenv('OWNER_ID'):
        await bot.tree.sync()
        await ctx.send('ok')
    else:
        await ctx.send('no')

bot.run(getenv('TOKEN'))