@@ -603,7 +603,8 @@ def wrapper(cmd):
603
603
604
604
return wrapper
605
605
606
- async def process_options (self , guild : discord .Guild , options : list , connector : dict ) -> dict :
606
+ async def process_options (self , guild : discord .Guild , options : list , connector : dict ,
607
+ temporary_auto_convert : dict = None ) -> dict :
607
608
"""
608
609
Processes Role, User, and Channel option types to discord.py's models.
609
610
@@ -612,6 +613,7 @@ async def process_options(self, guild: discord.Guild, options: list, connector:
612
613
:param options: Dict of options.
613
614
:type options: list
614
615
:param connector: Kwarg connector.
616
+ :param temporary_auto_convert: Temporary parameter, use this if options doesn't have ``type`` keyword.
615
617
:return: Union[list, dict]
616
618
"""
617
619
@@ -649,6 +651,12 @@ async def process_options(self, guild: discord.Guild, options: list, connector:
649
651
650
652
for x in options :
651
653
processed = None # This isn't the best way, but we should to reduce duplicate lines.
654
+
655
+ # This is to temporarily fix Issue #97, that on Android device
656
+ # does not give option type from API.
657
+ if "type" not in x :
658
+ x ["type" ] = temporary_auto_convert [x ["name" ]]
659
+
652
660
if x ["type" ] not in types :
653
661
processed = x ["value" ]
654
662
else :
@@ -731,8 +739,14 @@ async def on_socket_response(self, msg):
731
739
if "value" not in x :
732
740
return await self .handle_subcommand (ctx , to_use )
733
741
734
- args = await self .process_options (ctx .guild , to_use ["data" ]["options" ], selected_cmd .connector ) \
735
- if "options" in to_use ["data" ] else []
742
+ # This is to temporarily fix Issue #97, that on Android device
743
+ # does not give option type from API.
744
+ temporary_auto_convert = {}
745
+ for x in selected_cmd .options :
746
+ temporary_auto_convert [x ["name" ]] = x ["type" ]
747
+
748
+ args = await self .process_options (ctx .guild , to_use ["data" ]["options" ], selected_cmd .connector , temporary_auto_convert ) \
749
+ if "options" in to_use ["data" ] else {}
736
750
737
751
self ._discord .dispatch ("slash_command" , ctx )
738
752
@@ -764,14 +778,28 @@ async def handle_subcommand(self, ctx: context.SlashContext, data: dict):
764
778
return
765
779
ctx .subcommand_group = sub_group
766
780
selected = base [sub_name ][sub_group ]
767
- args = await self .process_options (ctx .guild , x ["options" ], selected .connector ) \
768
- if "options" in x else []
781
+
782
+ # This is to temporarily fix Issue #97, that on Android device
783
+ # does not give option type from API.
784
+ temporary_auto_convert = {}
785
+ for n in selected .options :
786
+ temporary_auto_convert [n ["name" ]] = n ["type" ]
787
+
788
+ args = await self .process_options (ctx .guild , x ["options" ], selected .connector , temporary_auto_convert ) \
789
+ if "options" in x else {}
769
790
self ._discord .dispatch ("slash_command" , ctx )
770
791
await self .invoke_command (selected , ctx , args )
771
792
return
772
793
selected = base [sub_name ]
773
- args = await self .process_options (ctx .guild , sub_opts , selected .connector ) \
774
- if "options" in sub else []
794
+
795
+ # This is to temporarily fix Issue #97, that on Android device
796
+ # does not give option type from API.
797
+ temporary_auto_convert = {}
798
+ for n in selected .options :
799
+ temporary_auto_convert [n ["name" ]] = n ["type" ]
800
+
801
+ args = await self .process_options (ctx .guild , sub_opts , selected .connector , temporary_auto_convert ) \
802
+ if "options" in sub else {}
775
803
self ._discord .dispatch ("slash_command" , ctx )
776
804
await self .invoke_command (selected , ctx , args )
777
805
0 commit comments