-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
75 lines (62 loc) · 2.02 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
from __future__ import annotations
import discord
import logging
import configs # type: ignore
from discord.ext import commands
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from asyncpg import Pool
from _types.context import GuildContext
_log = logging.getLogger(__name__)
cogs = ("cogs.management", "cogs.webhook", "cogs.admin")
class SteveBot(commands.Bot):
user: discord.ClientUser
pool: Pool
def __init__(self) -> None:
intents = discord.Intents(
members=True,
messages=True,
guilds=True,
)
super().__init__(
intents=intents,
# Command prefix is only used for :command:`sync`
command_prefix=commands.when_mentioned,
owner_ids=configs.owner_ids,
activity=discord.Game(name=configs.bot_status),
)
async def setup_hook(self) -> None:
for cog in cogs:
try:
await self.load_extension(cog)
except Exception:
_log.exception("Failed to load extension %s", cog)
async def on_ready(self):
_log.info(
f"Ready up: %s#%s",
self.user.name,
self.user.discriminator,
)
_log.info(
"developer: MartimMartins @ [email protected]",
)
_log.info(
"copyright: InviteManager @ invite-manager.net",
)
_log.info(
"licence: MIT",
)
async def start(self) -> None:
await super().start(configs.token, reconnect=True)
async def on_command_error(
self, ctx: GuildContext, error: commands.CommandError
) -> None:
if isinstance(error, commands.BadArgument):
e = discord.Embed(color=discord.Color.red(), description=str(error))
await ctx.send(embed=e)
elif isinstance(error, commands.HybridCommandError):
original = error.original
raise original
@property
def configs(self):
return __import__("configs")