-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
64 lines (52 loc) · 1.65 KB
/
bot.py
File metadata and controls
64 lines (52 loc) · 1.65 KB
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
import logging
from typing import Tuple, TypeAlias
import aiohttp
import discord
from discord.ext import commands
from discord.ext.commands import errors
try:
from typing import Self
except ImportError:
from typing_extensions import Self
log = logging.getLogger("bot")
EXTENSIONS: Tuple[str, ...] = (
"cogs.utility",
"cogs.support",
"cogs.welcome",
"cogs.webserver",
)
class GiftifyHelper(commands.Bot):
user: discord.ClientUser
def __init__(
self: Self,
logger: logging.Logger,
session: aiohttp.ClientSession,
*args,
**kwargs,
):
self.logger = logger
self.session = session
super().__init__(
*args,
**kwargs,
command_prefix=commands.when_mentioned_or("."),
intents=discord.Intents.all(),
allowed_mentions=discord.AllowedMentions(everyone=False, roles=False),
case_insensitive=True,
help_command=None,
activity=discord.Game(name="with Giftify"),
)
async def on_ready(self: Self):
log.info(f"Logged in as {self.user.display_name} ({self.user.id}).")
async def setup_hook(self: Self):
await self.load_extension("jishaku")
for extension in EXTENSIONS:
await self.load_extension(extension)
async def on_command_error(
self, ctx: commands.Context[Self], error: errors.CommandError
):
if not isinstance(error, commands.CommandInvokeError):
await ctx.send(str(error))
# Type Aliases
Context: TypeAlias = commands.Context[GiftifyHelper]
Interaction: TypeAlias = discord.Interaction[GiftifyHelper]