-
Notifications
You must be signed in to change notification settings - Fork 52
/
bot.py
96 lines (78 loc) · 2.1 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import aiohttp
import discord
from discord.ext import commands, events
from discord.ext.events import member_kick
import config
from helpers.context import GuiduckContext
ESSENTIAL_COGS = [
"bot",
"data",
"help",
"mongo",
"logging",
"redis",
]
COGS = [
"automod",
"autopost",
"auto_lock_threads",
"collectors",
"forms",
"giveaways",
"help_desk",
"levels",
"moderation",
"names",
"poketwo_administration",
"reaction_roles",
"reminders",
"reputation",
"role_sync",
"tags",
"outline",
]
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
async def _async_setup_hook(self):
await super()._async_setup_hook()
self.http.connector = aiohttp.TCPConnector(limit=0)
async def setup_hook(self):
self.http_session = aiohttp.ClientSession()
await self.load_extension("jishaku")
for i in ESSENTIAL_COGS:
await self.load_extension(f"cogs.{i}")
for i in COGS:
await 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 poketwo_redis(self):
return self.get_cog("Redis").poketwo_pool
@property
def log(self):
return self.get_cog("Logging").log
@property
def data(self):
return self.get_cog("Data").instance
async def on_ready(self):
self.log.info(f"Ready called.")
async def close(self):
self.log.info("Shutting down")
await super().close()
async def get_context(self, origin, /, *, cls=GuiduckContext):
return await super().get_context(origin, cls=cls)
if __name__ == "__main__":
bot = Bot()
bot.run(config.BOT_TOKEN)