-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtbot2.py
28 lines (21 loc) · 919 Bytes
/
rtbot2.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
import discord, os, asyncio, aiomysql, json
from discord.ext import commands
with open("./config/config.json", "r", encoding='UTF8') as db_json: config = json.load(db_json)
loop = asyncio.get_event_loop()
async def connect_db():
pool = await aiomysql.create_pool(
host=config["db"]["host"],
user=config["db"]["user"],
password=config["db"]["password"],
db=config["db"]["db"],
charset=config["db"]["charset"],
autocommit=True,
maxsize=10000
)
return pool
pool = loop.run_until_complete(connect_db())
client = commands.AutoShardedBot(command_prefix=config["command_prefix"],intents=discord.Intents.default())
client.pool = pool
for ext in filter(lambda x: x.endswith('.py') and not x.startswith('_'), os.listdir('./exts')):
client.load_extension('exts.' + os.path.splitext(ext)[0])
client.run(config["token"])