-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
74 lines (54 loc) · 2.17 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
67
68
69
70
71
72
73
74
import os
from logging import Logger
import discord
from discord.ext import commands
import utils.logger
import utils.sqlite
import utils.startup
class Tabuu3(commands.Bot):
def __init__(self) -> None:
super().__init__(
command_prefix="%",
intents=discord.Intents.all(),
status=discord.Status.online,
)
# The main prefix, used for listening to macros and display purposes mainly.
# This will only really matter if we set multiple command_prefixes in the future.
self.main_prefix = "%"
# To be used in the stats command.
self.version_number = "9.37.0"
self.matchmaking_pings = {
"singles": {},
"doubles": {},
"funnies": {},
"ranked": {},
}
# A check to make sure persistent buttons do not get added twice.
self.modmail_button_added = None
# A consistent colour for embeds.
self.colour = 0x007377
# The time we store matchmaking pings for, in seconds.
self.matchmaking_ping_time = 1800
# A dict of recent messages, used for the level system.
self.recent_messages = {}
async def setup_hook(self) -> None:
# We need to set up some stuff at startup.
utils.logger.create_logger()
utils.startup.generate_files()
await utils.sqlite.setup_db()
await utils.sqlite.setup_ufd()
for filename in os.listdir(r"./cogs"):
if filename.endswith(".py"):
await self.load_extension(f"cogs.{filename[:-3]}")
def get_logger(self, name: str) -> Logger:
# Just attaching it to the bot so we dont have to import it everywhere.
return utils.logger.get_logger(name)
async def on_ready(self) -> None:
print(
f"Lookin' good, connected as: {str(bot.user)}, at: {discord.utils.utcnow().strftime('%d-%m-%Y %H:%M:%S')} UTC"
)
bot = Tabuu3()
with open(r"./files/token.txt", encoding="utf-8") as f:
token = f.readline()
# We have our own logger, so we disable the default one.
bot.run(token, log_handler=None)