@@ -782,4 +782,68 @@ async def kill_process(self, interaction: discord.Interaction, pid: int) -> None
782
782
logging .exception (msg = out_msg )
783
783
await self ._interaction_followup_send_no_limit (interaction = interaction , msg = out_msg )
784
784
785
+ async def list_commands (self , interaction : discord .Interaction ) -> None :
786
+ if not self ._check_if_valid_guild (guild = interaction .guild ):
787
+ return
788
+ if not (await self ._is_bot_channel_interaction (interaction = interaction , send_message_if_not_bot = True )):
789
+ return
790
+
791
+ # Indiquer que la commande est en cours de traitement
792
+ await interaction .response .defer ()
793
+
794
+ try :
795
+ is_private : bool = self ._is_private_channel (channel = interaction .channel ) # type: ignore
796
+ # Récupérer la liste des commandes disponibles
797
+ out_msg : str = await self .monitoring .list_commands (is_private = is_private )
798
+
799
+ # Répondre à l'utilisateur
800
+ await self ._interaction_followup_send_no_limit (interaction = interaction , msg = out_msg )
801
+ except Exception as e :
802
+ out_msg = f"**Internal error retrieving available commands**:\n ```sh\n { e } \n ```"
803
+ logging .exception (msg = out_msg )
804
+ await self ._interaction_followup_send_no_limit (interaction = interaction , msg = out_msg )
805
+
806
+
807
+ async def execute_command (self , interaction : discord .Interaction , command_name : str ) -> None :
808
+ if not self ._check_if_valid_guild (guild = interaction .guild ):
809
+ return
810
+ if not (await self ._is_bot_channel_interaction (interaction = interaction , send_message_if_not_bot = True )):
811
+ return
812
+
813
+ # Indiquer que la commande est en cours de traitement
814
+ await interaction .response .defer ()
815
+
816
+ try :
817
+ is_private : bool = self ._is_private_channel (channel = interaction .channel ) # type: ignore
818
+ # Exécuter la commande demandée
819
+ out_msg : str = await self .monitoring .execute_command (is_private = is_private , command_name = command_name )
820
+
821
+ # Répondre à l'utilisateur
822
+ await self ._interaction_followup_send_no_limit (interaction = interaction , msg = out_msg )
823
+ except Exception as e :
824
+ out_msg = f"**Internal error executing command '{ command_name } '**:\n ```sh\n { e } \n ```"
825
+ logging .exception (msg = out_msg )
826
+ await self ._interaction_followup_send_no_limit (interaction = interaction , msg = out_msg )
827
+
828
+ async def execute_all_commands (self , interaction : discord .Interaction ) -> None :
829
+ if not self ._check_if_valid_guild (guild = interaction .guild ):
830
+ return
831
+ if not (await self ._is_bot_channel_interaction (interaction = interaction , send_message_if_not_bot = True )):
832
+ return
833
+
834
+ # Indiquer que la commande est en cours de traitement
835
+ await interaction .response .defer ()
836
+
837
+ try :
838
+ is_private : bool = self ._is_private_channel (channel = interaction .channel ) # type: ignore
839
+ # Exécuter toutes les commandes
840
+ out_msg : str = await self .monitoring .execute_all_commands (is_private = is_private )
841
+
842
+ # Répondre à l'utilisateur
843
+ await self ._interaction_followup_send_no_limit (interaction = interaction , msg = out_msg )
844
+ except Exception as e :
845
+ out_msg = f"**Internal error executing all commands**:\n ```sh\n { e } \n ```"
846
+ logging .exception (msg = out_msg )
847
+ await self ._interaction_followup_send_no_limit (interaction = interaction , msg = out_msg )
848
+
785
849
#endregion
0 commit comments