Skip to content

Commit 41c7ca8

Browse files
committed
Added subcommand, subcommand_group to SlashContext`
1 parent fae5da3 commit 41c7ca8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

discord_slash/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,14 @@ async def handle_subcommand(self, ctx: model.SlashContext, data: dict):
403403
sub_name = sub["name"]
404404
if sub_name not in base.keys():
405405
return
406+
ctx.subcommand = sub_name
406407
sub_opts = sub["options"] if "options" in sub else []
407408
for x in sub_opts:
408409
if "options" in x.keys() or "value" not in x.keys():
409410
sub_group = x["name"]
410411
if sub_group not in base[sub_name].keys():
411412
return
413+
ctx.subcommand_group = sub_group
412414
selected = base[sub_name][sub_group]
413415
args = await self.process_options(ctx.guild, x["options"], selected["auto_convert"]) \
414416
if "options" in x.keys() else []

discord_slash/model.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class SlashContext:
1414
Do not manually init this model.
1515
1616
:ivar name: Name of the command.
17+
:ivar subcommand: Subcommand of the command.
18+
:ivar subcommand_group: Subcommand group of the command.
1719
:ivar interaction_id: Interaction ID of the command message.
1820
:ivar command_id: ID of the command.
1921
:ivar _http: :class:`.http.SlashCommandRequest` of the client.
@@ -32,6 +34,8 @@ def __init__(self,
3234
logger):
3335
self.__token = _json["token"]
3436
self.name = _json["data"]["name"]
37+
self.subcommand = None
38+
self.subcommand_group = None
3539
self.interaction_id = _json["id"]
3640
self.command_id = _json["data"]["id"]
3741
self._http = _http

0 commit comments

Comments
 (0)