@@ -245,27 +245,28 @@ def handle_dispatch(self, event: str, data: dict) -> None:
245245 :type data: dict
246246 """
247247
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" ):
253253 for group_option in option ["options" ]:
254- _kwargs ["sub_command" ] = group_option ["name" ]
254+ kwargs ["sub_command" ] = group_option ["name" ]
255255 if group_option .get ("options" ):
256256 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" ):
260261 for sub_option in option ["options" ]:
261- _kwargs [sub_option ["name" ]] = sub_option ["value" ]
262+ kwargs [sub_option ["name" ]] = sub_option ["value" ]
262263 else :
263- _kwargs [option . name ] = option . value
264+ kwargs [option [ ' name' ]] = option [ ' value' ]
264265
265- return _kwargs
266+ return kwargs
266267
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" ):
269270 if option ["type" ] == OptionType .SUB_COMMAND_GROUP :
270271 for group_option in option ["options" ]:
271272 if group_option .get ("options" ):
@@ -313,15 +314,15 @@ def check_sub_auto(option) -> tuple:
313314 if context .data ._json .get ("options" ):
314315 if context .data .options :
315316 for option in context .data .options :
316- _kwargs .update (check_sub_command (option ))
317+ _kwargs .update (check_sub_command (option if isinstance ( option , dict ) else option . _json ))
317318 elif data ["type" ] == InteractionType .MESSAGE_COMPONENT :
318319 _name = context .data .custom_id
319320 elif data ["type" ] == InteractionType .APPLICATION_COMMAND_AUTOCOMPLETE :
320321 _name = "autocomplete_"
321322 if context .data ._json .get ("options" ):
322323 if context .data .options :
323324 for option in context .data .options :
324- add_name , add_args = check_sub_auto (option )
325+ add_name , add_args = check_sub_auto (option if isinstance ( option , dict ) else option . _json )
325326 if add_name :
326327 _name += add_name
327328 if add_args :
0 commit comments