Skip to content

Commit 7993edb

Browse files
Implement ctx.cog for AutocompleteContext
1 parent 85031d6 commit 7993edb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

discord/commands/context.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
if TYPE_CHECKING:
3232
import discord
33+
from discord import Bot
3334
from discord.state import ConnectionState
3435

3536
from .commands import ApplicationCommand, Option
@@ -65,7 +66,7 @@ class ApplicationContext(discord.abc.Messageable):
6566
The command that this context belongs to.
6667
"""
6768

68-
def __init__(self, bot: "discord.Bot", interaction: Interaction):
69+
def __init__(self, bot: Bot, interaction: Interaction):
6970
self.bot = bot
7071
self.interaction = interaction
7172
self.command: ApplicationCommand = None # type: ignore
@@ -174,3 +175,11 @@ def __init__(self, interaction: Interaction, *, command: ApplicationCommand, foc
174175
self.focused = focused
175176
self.value = value
176177
self.options = options
178+
179+
@property
180+
def cog(self) -> Optional[Cog]:
181+
"""Optional[:class:`.Cog`]: Returns the cog associated with this context's command. None if it does not exist."""
182+
if self.command is None:
183+
return None
184+
185+
return self.command.cog

0 commit comments

Comments
 (0)