@@ -114,6 +114,22 @@ def channel(self) -> typing.Optional[typing.Union[discord.TextChannel, discord.D
114114 """
115115 return self .bot .get_channel (self .channel_id )
116116
117+ @property
118+ def voice_client (self ):
119+ """
120+ VoiceClient instance of the command invoke. If the command was invoked in DM, then it is ``None``.
121+ If the bot is not connected to any Voice/Stage channels, then it is ``None``.
122+
123+ """
124+ return self .guild .voice_client if self .guild else None
125+
126+ @property
127+ def me (self ):
128+ """
129+ Similar to :attr:`.Guild.me` except that it may also return the bot user in DM context.
130+ """
131+ return self .guild .me if self .guild is not None else self .bot .user
132+
117133 async def defer (self , hidden : bool = False ):
118134 """
119135 'Defers' the response, showing a loading state to the user
@@ -282,9 +298,24 @@ def __init__(
282298 self .subcommand_name = self .invoked_subcommand = self .subcommand_passed = None
283299 self .subcommand_group = self .invoked_subcommand_group = self .subcommand_group_passed = None
284300 self .command_id = _json ["data" ]["id" ]
301+ self ._discord = _discord
285302
286303 super ().__init__ (_http = _http , _json = _json , _discord = _discord , logger = logger )
287304
305+ @property
306+ def cog (self ) -> typing .Optional [commands .Cog ]:
307+ """
308+ Returns the cog associated with the command invoked, if any.
309+ """
310+
311+ # noinspection PyUnresolvedReferences
312+ cmd_obj = self ._discord .slash .commands [self .command ] # above line, thanks PyCharm
313+
314+ if isinstance (cmd_obj , (model .CogBaseCommandObject , model .CogSubcommandObject )):
315+ return cmd_obj .cog
316+ else :
317+ return None
318+
288319
289320class ComponentContext (InteractionContext ):
290321 """
0 commit comments