Skip to content

Commit 1761f22

Browse files
Add kwargs and args attrs to context
Resolves #115
1 parent 4d974f5 commit 1761f22

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

discord_slash/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,15 @@ async def invoke_command(self, func, ctx, args):
691691
try:
692692
not_kwargs = False
693693
if isinstance(args, dict):
694+
ctx.kwargs = args
695+
ctx.args = list(args.values())
694696
try:
695697
await func.invoke(ctx, **args)
696698
except TypeError:
697699
args = list(args.values())
698700
not_kwargs = True
699701
else:
702+
ctx.args = args
700703
not_kwargs = True
701704
if not_kwargs:
702705
await func.invoke(ctx, *args)

discord_slash/context.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class SlashContext:
1818
1919
:ivar message: Message that invoked the slash command.
2020
:ivar name: Name of the command.
21+
:ivar args: List of processed arguments invoked with the command.
22+
:ivar kwargs: Dictionary of processed arguments invoked with the command.
2123
:ivar subcommand_name: Subcommand of the command.
2224
:ivar subcommand_group: Subcommand group of the command.
2325
:ivar interaction_id: Interaction ID of the command message.
@@ -40,6 +42,8 @@ def __init__(self,
4042
self.__token = _json["token"]
4143
self.message = None # Should be set later.
4244
self.name = self.command = self.invoked_with = _json["data"]["name"]
45+
self.args = []
46+
self.kwargs = {}
4347
self.subcommand_name = self.invoked_subcommand = self.subcommand_passed = None
4448
self.subcommand_group = self.invoked_subcommand_group = self.subcommand_group_passed = None
4549
self.interaction_id = _json["id"]

0 commit comments

Comments
 (0)