-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
56 lines (47 loc) · 1.54 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
import logging
import os
import aiohttp
import disnake
from disnake.ext import commands
from utils import settings
from utils.checks import is_mod
logger = logging.getLogger("bot")
help_command = commands.MinimalHelpCommand()
class Squire(commands.Bot):
def __init__(self, started_at, **kwargs):
super().__init__(
command_prefix=settings.prefix,
description="sQUIRE, Defender of Bikini Bottom",
help_command=help_command,
intents=settings.intents,
**kwargs,
)
self.version = settings.version
self.started_at = started_at
self.session = aiohttp.ClientSession()
self.add_check(lambda ctx: is_mod(ctx.author))
self._exit_code = 0
async def on_ready(self):
logger.info(f"Logged in as {self.user}. Bot is ready.")
async def on_message(self, message):
# ignore bots
if message.author.bot:
return
# process_commands
else:
await self.process_commands(message)
def load_cogs(self):
logger.info("Loading cogs.")
for cog in settings.COGS:
try:
self.load_extension(cog)
logger.info(f" - {cog}")
except commands.ExtensionFailed as e:
logger.exception(
f"Failed to load cog {cog} [{e.__class__.__name__}: {e}]"
)
logger.info("Cogs loaded.")
async def close(self):
await self.session.close()
del self.session
await super().close()