aboutsummaryrefslogtreecommitdiff
path: root/bot.py
blob: 15b7421b761fe6420651e530314ddcd79c18bd17 (plain)
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.ext import commands
import os
from database import Base, engine

import config as config
from src.utils.command_tree import Tree


class MyBot(commands.Bot):
    def __init__(self):
        super().__init__(
            command_prefix="***",
            intents=discord.Intents.default(),
            tree_cls=Tree,
        )

    async def setup_hook(self):
        for ext in os.listdir("./src/cogs"):
            if ext.endswith(".py"):
                await self.load_extension(f"src.cogs.{ext[:-3]}")

        for ext in os.listdir("./src/cogs/owner"):
            if ext.endswith(".py"):
                await self.load_extension(f"src.cogs.owner.{ext[:-3]}")

    async def on_ready(self):
        Base.metadata.create_all(bind=engine)
        config.LOG.info(f"{bot.user} has connected to Discord.")
        config.LOG.info(
            "Startup complete. Sync slash commands by DMing the bot"
            f" {bot.command_prefix}tree sync (guild id)"
        )


bot = MyBot()
bot.remove_command("help")


if __name__ == "__main__":
    config.load_config()
    bot.run(config.TOKEN)