Skip to content

Commit 086e1c3

Browse files
committed
Fixed KeyError at unexpected auto_convert format #16
1 parent 28f8744 commit 086e1c3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

discord_slash/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ async def _pick(ctx, choice1, choice2): # Command with 1 or more args.
178178
auto_convert = {}
179179
for x in options:
180180
if x["type"] < 3:
181-
raise Exception("Currently subcommand is NOT supported.")
181+
raise Exception("Please use `subcommand()` decorator for subcommands!")
182182
auto_convert[x["name"]] = x["type"]
183183

184184
def wrapper(cmd):
@@ -218,8 +218,9 @@ async def _group_say(ctx, _str):
218218
:param guild_ids: List of guild ID of where the command will be used. Default ``None``, which will be global command.
219219
:return:
220220
"""
221-
raise NotImplementedError
221+
222222
def wrapper(cmd):
223+
self.add_subcommand(cmd, base, subcommand_group, name, description, auto_convert, guild_ids)
223224
return cmd
224225
return wrapper
225226

@@ -240,7 +241,7 @@ def process_options(self, guild: discord.Guild, options: list, auto_convert: dic
240241
return [x["value"] for x in options]
241242
if not auto_convert:
242243
return [x["value"] for x in options]
243-
converters = [guild.get_member, guild.get_role, guild.get_role]
244+
converters = [guild.get_member, guild.get_channel, guild.get_role]
244245
types = {
245246
"user": 0,
246247
"USER": 0,
@@ -261,6 +262,9 @@ def process_options(self, guild: discord.Guild, options: list, auto_convert: dic
261262
for x in options:
262263
selected = x
263264
if selected["name"] in auto_convert.keys():
265+
if auto_convert[selected["name"]] not in types.keys():
266+
to_return.append(selected["value"])
267+
continue
264268
loaded_converter = converters[types[auto_convert[selected["name"]]]]
265269
to_return.append(loaded_converter(int(selected["value"])))
266270
return to_return

0 commit comments

Comments
 (0)