@@ -245,27 +245,28 @@ def handle_dispatch(self, event: str, data: dict) -> None:
245
245
:type data: dict
246
246
"""
247
247
248
- def check_sub_command (option ) -> dict :
249
- _kwargs = dict ()
250
- if option . _json . get ( "options" ) :
251
- if option [ "type " ] == OptionType . SUB_COMMAND_GROUP :
252
- _kwargs [ "sub_command_group" ] = option [ "name" ]
248
+ def check_sub_command (option : dict ) -> dict :
249
+ kwargs = dict ()
250
+ if option [ "type" ] == OptionType . SUB_COMMAND_GROUP :
251
+ kwargs [ "sub_command_group " ] = option [ "name" ]
252
+ if option . get ( "options" ):
253
253
for group_option in option ["options" ]:
254
- _kwargs ["sub_command" ] = group_option ["name" ]
254
+ kwargs ["sub_command" ] = group_option ["name" ]
255
255
if group_option .get ("options" ):
256
256
for sub_option in group_option ["options" ]:
257
- _kwargs [sub_option ["name" ]] = sub_option ["value" ]
258
- elif option ["type" ] == OptionType .SUB_COMMAND :
259
- _kwargs ["sub_command" ] = option ["name" ]
257
+ kwargs [sub_option ["name" ]] = sub_option ["value" ]
258
+ elif option ["type" ] == OptionType .SUB_COMMAND :
259
+ kwargs ["sub_command" ] = option ["name" ]
260
+ if option .get ("options" ):
260
261
for sub_option in option ["options" ]:
261
- _kwargs [sub_option ["name" ]] = sub_option ["value" ]
262
+ kwargs [sub_option ["name" ]] = sub_option ["value" ]
262
263
else :
263
- _kwargs [option . name ] = option . value
264
+ kwargs [option [ " name" ]] = option [ " value" ]
264
265
265
- return _kwargs
266
+ return kwargs
266
267
267
- def check_sub_auto (option ) -> tuple :
268
- if option ._json . get ("options" ):
268
+ def check_sub_auto (option : dict ) -> tuple :
269
+ if option .get ("options" ):
269
270
if option ["type" ] == OptionType .SUB_COMMAND_GROUP :
270
271
for group_option in option ["options" ]:
271
272
if group_option .get ("options" ):
@@ -313,15 +314,21 @@ def check_sub_auto(option) -> tuple:
313
314
if context .data ._json .get ("options" ):
314
315
if context .data .options :
315
316
for option in context .data .options :
316
- _kwargs .update (check_sub_command (option ))
317
+ _kwargs .update (
318
+ check_sub_command (
319
+ option if isinstance (option , dict ) else option ._json
320
+ )
321
+ )
317
322
elif data ["type" ] == InteractionType .MESSAGE_COMPONENT :
318
323
_name = context .data .custom_id
319
324
elif data ["type" ] == InteractionType .APPLICATION_COMMAND_AUTOCOMPLETE :
320
325
_name = "autocomplete_"
321
326
if context .data ._json .get ("options" ):
322
327
if context .data .options :
323
328
for option in context .data .options :
324
- add_name , add_args = check_sub_auto (option )
329
+ add_name , add_args = check_sub_auto (
330
+ option if isinstance (option , dict ) else option ._json
331
+ )
325
332
if add_name :
326
333
_name += add_name
327
334
if add_args :
0 commit comments