forked from TheXer/Jachym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
39 lines (29 loc) · 1.07 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
import os
import discord
from aiomysql import create_pool
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv("password.env")
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
USER = os.getenv("USER_DATABASE")
PASSWORD = os.getenv("PASSWORD")
HOST = os.getenv("HOST")
DATABASE = os.getenv("DATABASE")
# Co jsou intents? https://discordpy.readthedocs.io/en/stable/intents.html
intents = discord.Intents.all()
bot = commands.AutoShardedBot(
command_prefix=commands.when_mentioned_or("!"),
intents=intents,
help_command=None)
# This is important for adding new variable (database) to Bot instance so I can use it in cogs.
@bot.event
async def on_ready():
bot.pool = await create_pool(user=USER, password=PASSWORD, host=HOST, db=DATABASE)
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
try:
bot.load_extension(f"cogs.{filename[:-3]}")
print(f"{filename[:-3]} has loaded successfully")
except Exception as error:
raise error
bot.run(DISCORD_TOKEN)