-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtex_bot_contexts.py
More file actions
46 lines (29 loc) · 1.42 KB
/
tex_bot_contexts.py
File metadata and controls
46 lines (29 loc) · 1.42 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
"""
Type-hinting classes that override the Pycord Context classes.
These custom, overridden classes contain a reference to the custom bot class TeXBot,
rather than Pycord's default Bot class.
"""
from typing import TYPE_CHECKING
import discord
if TYPE_CHECKING:
from collections.abc import Awaitable, Callable, Sequence
from discord import Interaction, WebhookMessage
from utils.tex_bot import TeXBot
__all__: "Sequence[str]" = ("TeXBotApplicationContext", "TeXBotAutocompleteContext")
class TeXBotAutocompleteContext(discord.AutocompleteContext):
"""
Type-hinting class overriding AutocompleteContext's reference to the Bot class.
Pycord's default AutocompleteContext references Pycord's standard Bot class,
but cogs require a reference to the TeXBot class, so this AutocompleteContext subclass
should be used in cogs instead.
"""
bot: "TeXBot" # type: ignore[mutable-override]
class TeXBotApplicationContext(discord.ApplicationContext):
"""
Type-hinting class overriding ApplicationContext's reference to the Bot class.
Pycord's default ApplicationContext references Pycord's standard Bot class,
but cogs require a reference to the TeXBot class, so this ApplicationContext subclass
should be used in cogs instead.
"""
bot: "TeXBot" # type: ignore[mutable-override]
respond: "Callable[..., Awaitable[Interaction | WebhookMessage]]" # type: ignore[explicit-any]