This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
46 lines (38 loc) · 1.38 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
43
44
45
46
import asyncio
import datetime
import os
import traceback
import aioredis
import asyncpg
from aiohttp import ClientSession
from discord.ext import commands
import config
from classes.bot import Bot
async def run():
bot = Bot(command_prefix=commands.when_mentioned_or(config.command_prefix))
bot.remove_command("help")
bot.pool = await asyncpg.create_pool(**config.postgres_login)
bot.redis = await aioredis.create_pool("redis://localhost")
bot.session = ClientSession()
bot.config = config
bot.started_at = datetime.datetime.now()
try:
for file in os.listdir("cogs"):
if file.endswith(".py"):
try:
bot.load_extension(f"cogs.{file[:-3]}")
print("successfully loaded cog", file[:-3])
except Exception:
with open("error.log", "a+") as error_log:
error_log.write(
"#############################################\n"
)
traceback.print_exc(file=error_log)
error_log.close()
print(f"# Error loading {file}! See error.log for more info.")
bot.load_extension("jishaku")
await bot.start(config.token)
except KeyboardInterrupt:
await bot.logout()
loop = asyncio.get_event_loop()
loop.run_until_complete(run())