This repository has been archived by the owner on May 18, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 418
/
main.py
42 lines (33 loc) · 1.56 KB
/
main.py
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 os
from typing import Any
import discord
from discord.ext import commands
from dotenv import load_dotenv
from cogs import COMMANDS, EVENT_HANDLERS
from bot_utilities.config_loader import config
load_dotenv('.env')
class AIBot(commands.AutoShardedBot):
def __init__(self, *args: Any, **kwargs: Any) -> None:
if config['AUTO_SHARDING']:
super().__init__(*args, **kwargs)
else:
super().__init__(shard_count=1, *args, **kwargs)
async def setup_hook(self) -> None:
for cog in COMMANDS:
cog_name = cog.split('.')[-1]
discord.client._log.info(f"Loaded Command {cog_name}")
await self.load_extension(f"{cog}")
for cog in EVENT_HANDLERS:
cog_name = cog.split('.')[-1]
discord.client._log.info(f"Loaded Event Handler {cog_name}")
await self.load_extension(f"{cog}")
print('If syncing commands is taking longer than usual you are being ratelimited')
await self.tree.sync()
discord.client._log.info(f"Loaded {len(self.commands)} commands")
bot = AIBot(command_prefix=[], intents=discord.Intents.all(), help_command=None)
TOKEN = os.getenv('DISCORD_TOKEN')
if TOKEN is None:
print("\033[31mLooks like you haven't properly set up a Discord token environment variable in the `.env` file. (Secrets on replit)\033[0m")
print("\033[33mNote: If you don't have a Discord token environment variable, you will have to input it every time. \033[0m")
TOKEN = input("Please enter your Discord token: ")
bot.run(TOKEN, reconnect=True)