@@ -84,12 +84,24 @@ def get_syntax(cmnd):
84
84
embed .add_field (name = "Description" , value = cmnd .help , inline = True )
85
85
else :
86
86
embed .add_field (name = "Erreur : commande inconnue" , value = f"Entrez `{ self .PREFIX } aide` pour avoir la liste des commandes." )
87
-
87
+
88
+ await ctx .send (embed = embed )
89
+
88
90
else :
89
- embed = discord . Embed ( title = "Rubrique d'aide" , description = f"Entrez : ` { self . PREFIX } aide <commande>` pour plus d'informations." , color = 8421504 )
91
+ fields = []
90
92
for cmnd in self .get_commands ():
91
- embed .add_field (name = cmnd .brief , value = get_syntax (cmnd ), inline = False )
92
- await ctx .send (embed = embed )
93
+ fields .append ((cmnd .brief , get_syntax (cmnd )))
94
+
95
+ nb = len (fields ) // 25 + 1
96
+ index = 1
97
+ while fields :
98
+ embed = discord .Embed (title = f"Rubrique d'aide ({ index } /{ nb } )" , description = f"Entrez : `{ self .PREFIX } aide <commande>` pour plus d'informations." , color = 8421504 )
99
+ for field in fields [: 25 ]:
100
+ embed .add_field (name = field [0 ], value = field [1 ], inline = False )
101
+ fields = fields [25 : ]
102
+ index += 1
103
+ await ctx .send (embed = embed )
104
+
93
105
94
106
95
107
@commands .command (help = "Votre espèce est à préciser impérativement. Si aucun pseudonyme n'est précisé, Odyssée prendra votre nom d'utilisateur." , brief = "Créer un nouveau joueur" )
@@ -585,7 +597,6 @@ async def achat(self, ctx, nom: str, nombre: int=1):
585
597
if shop_id == - 1 : await send_error (ctx , f"__{ player .name } __ n'est pas dans un magasin" ); return
586
598
587
599
obj = get_official_name (nom .lower ())
588
- print (obj )
589
600
obj = get_object (obj , shop_id )
590
601
if obj .shop_id == - 1 : await send_error (ctx , f"cet objet : '{ nom } ' n'est pas vendu ici" ); return
591
602
@@ -868,4 +879,30 @@ async def etat(self, ctx, nouvel_etat: str):
868
879
else :
869
880
send_error (ctx , f"{ nouvel_etat } n'est pas un état connu" )
870
881
871
- self .save_game ()
882
+ self .save_game ()
883
+
884
+ @commands .command (name = "plante" , help = "Donne des informations sur la plante demandée (source : wikiphyto.org)" , brief = "Informations sur une plante" )
885
+ async def plante (self , ctx , nom : str ):
886
+ result , check_code = wikiphyto_api (nom )
887
+ # homonymie
888
+ if check_code == 0 :
889
+ embed = discord .Embed (title = nom , description = f"Plusieurs plantes correspondent à la recherche : '{ nom } '" , color = 8421504 )
890
+ embed .add_field (name = "Essayez un nom de plante suivant" , value = " ❖ " + " ❖ " .join (result ))
891
+ # pas de résultat
892
+ elif check_code == 1 :
893
+ embed = discord .Embed (title = nom , description = "Erreur" , color = 8421504 )
894
+ embed .add_field (name = "Plante non trouvée" , value = f"Aucune plante ne correspond à la recherche : '{ nom } '" )
895
+ # succès
896
+ else :
897
+ latin_name , description , used_parts , properties , img , url = result
898
+ embed = discord .Embed (title = nom , description = latin_name , color = 8421504 )
899
+ if img : embed .set_image (url = img )
900
+ embed .set_footer (text = url )
901
+ embed .add_field (name = "Description et habitat" , value = "\n " .join (description ), inline = True )
902
+ embed .add_field (name = "Parties utilisées" , value = "\n " .join (used_parts ), inline = True )
903
+ embed .add_field (name = "Propriétés de la plante" , value = "\n " .join (properties [0 ]), inline = False )
904
+ embed .add_field (name = "Propriétés du bourgeon" , value = "\n " .join (properties [1 ]), inline = True )
905
+ embed .add_field (name = "Propriétés de l'huile essentielle" , value = "\n " .join (properties [2 ]), inline = True )
906
+
907
+ await ctx .send (embed = embed )
908
+
0 commit comments