Bonjour,
J'ai commencé à créer un bot discord qui répond des "embed" messages selon certaines commandes. Or le paramètre color semble n'avoir aucun effet, je me retrouve toujours avec des messages blancs.
J'ai une fonction qui va chercher des valeurs dans une base de données (getValue).
Et la fonction getCard est appelée pour créer le "embed message" qui correspond à la carte demandée (c'est un discord de jeu de cartes).
Sauf quelque soit la couleur que je mets, ça ne change rien, mon message s'affiche en blanc
Je rajoute que si je lance la commande suivante (trouvée sur le net), j'ai bien le titre en bleu :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 def getCard(df,file): embed=discord.Embed(title="__"+getValue(df,"NOM")+"__", color = discord.Color.blue()) embed.add_field(name="***"+getValue(df,"FACTION")+"***", value="Cost: "+getValue(df,"COUT"), inline=False) embed.add_field(name="**"+getValue(df,"TRAITS")+"**", value=getValue(df,"TEXTE"), inline=False) embed.set_footer(text="**flavor text**") return embed @bot.command() async def carte(ctx, *, name: str): data_path = os.path.join(os.path.abspath(os.path.dirname( __file__)),DATA_FOLDER) for path, subdirs, files in os.walk(data_path): for f in files: result = pandas.read_csv(os.path.join(path,f), sep=';') df = result[result.NOM.str.contains(name, case=False, na=False)] if not df.empty: await ctx.send(embed=getCard(df,f))
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 @bot.command() async def embed(ctx): embed=discord.Embed( title="Text Formatting", url="https://realdrewdata.medium.com/", description="Here are some ways to format text", color=discord.Color.blue()) embed.add_field(name="*Italics*", value="Surround your text in asterisks (\*)", inline=False) embed.add_field(name="**Bold**", value="Surround your text in double asterisks (\*\*)", inline=False) embed.add_field(name="__Underline__", value="Surround your text in double underscores (\_\_)", inline=False) embed.add_field(name="~~Strikethrough~~", value="Surround your text in double tildes (\~\~)", inline=False) embed.add_field(name="`Code Chunks`", value="Surround your text in backticks (\`)", inline=False) embed.add_field(name="Blockquotes", value="> Start your text with a greater than symbol (\>)", inline=False) embed.add_field(name="Secrets", value="||Surround your text with double pipes (\|\|)||", inline=False) embed.set_footer(text="Learn more here: realdrewdata.medium.com") await ctx.send(embed=embed)
Partager