forked from oliver-ni/2022-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
76 lines (59 loc) · 1.67 KB
/
bot.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
75
76
from pathlib import Path
import discord
from discord.ext import commands, events, ipc
from discord.ext.events import member_kick
import config
DEFAULT_COGS = [
"automod",
"bot",
"events",
"help",
"info",
"logging",
"moderation",
"mongo",
"reaction_roles",
"redis",
"tags",
"verification",
]
class Bot(commands.Bot, events.EventsMixin):
def __init__(self, **kwargs):
super().__init__(
**kwargs,
command_prefix=config.PREFIX,
intents=discord.Intents.all(),
allowed_mentions=discord.AllowedMentions(everyone=False, roles=False),
case_insensitive=True,
)
self.config = config
self.ipc = ipc.Server(self, secret_key=config.SECRET_KEY)
self.load_extension("jishaku")
for i in DEFAULT_COGS:
self.load_extension(f"cogs.{i}")
for i in getattr(config, "EXTRA_COGS", []):
self.load_extension(f"cogs.{i}")
@property
def mongo(self):
return self.get_cog("Mongo")
@property
def redis(self):
return self.get_cog("Redis").pool
@property
def log(self):
return self.get_cog("Logging").log
async def on_ready(self):
print(f"Ready called.")
async def on_ipc_ready(self):
print("IPC is ready.")
async def on_ipc_error(self, endpoint, error):
print(endpoint, "raised", error)
async def close(self):
print("Shutting down")
await super().close()
if __name__ == "__main__":
Path("logs").mkdir(exist_ok=True)
Path("attachments").mkdir(exist_ok=True)
bot = Bot()
bot.ipc.start()
bot.run(config.BOT_TOKEN)