Skip to content

Commit 128dbae

Browse files
committed
Added options at decorator
1 parent 46b5cc8 commit 128dbae

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

discord_slash/client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def slash(self,
5151
5252
.. note::
5353
Role, User, and Channel types are passed as id if you don't set ``auto_convert``, since API doesn't give type of the option for now.\n
54-
Also, if ``options`` is passed, then ``auto_convert`` will be automatically created.
54+
Also, if ``options`` is passed, then ``auto_convert`` will be automatically created or overrided.
5555
5656
.. warning::
5757
Unlike discord.py's command, ``*args``, keyword-only args, converters, etc. are NOT supported.
@@ -83,6 +83,14 @@ async def _pick(ctx, choice1, choice2): # Command with 1 or more args.
8383
:param guild_id: Guild ID of where the command will be used. Default ``None``, which will be global command.
8484
:param options: Options of the slash command. This will affect ``auto_convert`` and command data at Discord API. Default ``None``.
8585
"""
86+
if options:
87+
# Overrides original auto_convert.
88+
auto_convert = {}
89+
for x in options:
90+
if x["type"] < 3:
91+
raise Exception("Currently subcommand is NOT supported.")
92+
auto_convert[x["name"]] = x["type"]
93+
8694
def wrapper(cmd):
8795
self.commands[cmd.__name__ if not name else name] = [cmd, auto_convert]
8896
self.logger.debug(f"Added command `{cmd.__name__ if not name else name}`")

discord_slash/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def send(self,
7373
"tts": tts,
7474
"embeds": [x.to_dict() for x in embeds] if embeds else [],
7575
"allowed_mentions": [x.to_dict() for x in allowed_mentions] if allowed_mentions
76-
else self._discord.allowed_mentions.to_dict() if self._discord.allowed_mentions else []
76+
else self._discord.allowed_mentions.to_dict() if self._discord.allowed_mentions else []
7777
}
7878
initial = True if not self.sent else False
7979
resp = await self._http.post(base, self._discord.user.id, self.interaction_id, self.__token, initial)

0 commit comments

Comments
 (0)