-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (37 loc) · 1.17 KB
/
main.py
File metadata and controls
51 lines (37 loc) · 1.17 KB
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
47
48
49
50
51
import asyncio
import os
import re
import traceback
import aiohttp
import aioscheduler
import asyncpg
import discord
from discord.ext import commands
from config import postgres_login, prefix, token
fallback = os.urandom(32).hex()
def get_pre(_, msg):
comp = re.compile("^(" + "|".join(map(re.escape, prefix)) + ").*", flags=re.I)
match = comp.match(msg.content)
if match is not None:
return match.group(1)
return fallback
intents = discord.Intents.default()
intents.members = True
intents.typing = True
async def start():
bot = commands.Bot(command_prefix=get_pre, intents=intents)
bot.session = aiohttp.ClientSession()
bot.scheduler = aioscheduler.TimedScheduler()
bot.scheduler.start()
bot.db = await asyncpg.connect(**postgres_login)
for cog in os.listdir("cogs"):
if cog.endswith(".py"):
try:
bot.load_extension(f"cogs.{cog[:-3]}")
print(f"{cog[:-3]} loaded successfully")
except commands.ExtensionError:
traceback.print_exc()
bot.load_extension("jishaku")
await bot.start(token)
loop = asyncio.get_event_loop()
loop.run_until_complete(start())