-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·66 lines (48 loc) · 1.6 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import sys
import traceback
from typing import Any, Dict, Optional
import aiohttp
import asyncpg
import discord
import uvicorn
from discord.ext import commands
from dotenv import load_dotenv
import utils
from cogs import EXTENSIONS
class GuildInfoTool(commands.Bot):
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
async def setup_hook(self) -> None:
for cog in EXTENSIONS:
try:
await self.load_extension(f"{cog}")
except commands.errors.ExtensionError:
traceback.print_exc()
self.session = aiohttp.ClientSession()
self.db = await asyncpg.create_pool(os.getenv("PSQL_URL"), record_class=utils.CustomRecordClass)
async def close(self) -> None:
await self.session.close()
await self.db.close()
await super().close()
async def on_error(self, event, *args: Any, **kwargs: Any) -> None:
more_information = sys.exc_info()
error_wanted = traceback.format_exc()
traceback.print_exc()
# print(event)
# print(more_information[0])
# print(args)
# print(kwargs)
# check about on_error with other repos of mine as well to update this.
if not os.getenv("TOKEN"):
load_dotenv()
bot = GuildInfoTool(
command_prefix=commands.when_mentioned_or("g$"),
intents=discord.Intents.all(),
strip_after_prefix=True,
)
@bot.event
async def on_ready():
print(bot.user)
print(bot.user.id)
bot.run(os.environ["TOKEN"])