@@ -413,8 +413,13 @@ async def process_options(self, guild: discord.Guild, options: list, auto_conver
413
413
if not guild :
414
414
self .logger .info ("This command invoke is missing guild. Skipping option process." )
415
415
return [x ["value" ] for x in options ]
416
+
417
+ if not isinstance (guild , discord .Guild ):
418
+ return [x ["value" ] for x in options ]
419
+
416
420
if not auto_convert :
417
421
return [x ["value" ] for x in options ]
422
+
418
423
converters = [
419
424
[guild .get_member , guild .fetch_member ],
420
425
guild .get_channel ,
@@ -471,21 +476,37 @@ async def on_socket_response(self, msg):
471
476
"""
472
477
if msg ["t" ] != "INTERACTION_CREATE" :
473
478
return
479
+
474
480
to_use = msg ["d" ]
481
+
475
482
if to_use ["data" ]["name" ] in self .commands .keys ():
483
+
476
484
ctx = model .SlashContext (self .req , to_use , self ._discord , self .logger )
477
485
cmd_name = to_use ["data" ]["name" ]
486
+
478
487
if cmd_name not in self .commands .keys () and cmd_name in self .subcommands .keys ():
479
488
return await self .handle_subcommand (ctx , to_use )
489
+
480
490
selected_cmd = self .commands [to_use ["data" ]["name" ]]
491
+
481
492
if selected_cmd .allowed_guild_ids :
482
- if ctx .guild .id not in selected_cmd .allowed_guild_ids :
493
+ guild_id = (
494
+ ctx .guild .id if isinstance (ctx .guild , discord .Guild )
495
+ else
496
+ ctx .guild
497
+ )
498
+
499
+ if guild_id not in selected_cmd .allowed_guild_ids :
483
500
return
501
+
484
502
if selected_cmd .has_subcommands :
485
503
return await self .handle_subcommand (ctx , to_use )
504
+
486
505
args = await self .process_options (ctx .guild , to_use ["data" ]["options" ], selected_cmd .auto_convert ) \
487
506
if "options" in to_use ["data" ] else []
507
+
488
508
self ._discord .dispatch ("slash_command" , ctx )
509
+
489
510
try :
490
511
await selected_cmd .invoke (ctx , * args )
491
512
except Exception as ex :
0 commit comments