我创建了一个不和谐的机器人(在 python 中),当我们使用一些命令时它会回答“嵌入消息”。
我有一个函数(getValue),它从数据库返回一些数据,并启动函数 getCard 以根据请求的卡片创建“嵌入消息”(这是纸牌游戏的不和谐)。
但是颜色参数不起作用,嵌入消息总是白色的,为什么?
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))
请注意,此代码正在工作并以蓝色显示(在线找到),但我看不出有什么区别:
@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)```