discord bot 设置嵌入消息颜色
discord bot set embed message color
所以我写了这个发送嵌入消息的代码,如果你写000000
它会使嵌入变成黑色,但是如果你写ff0000
红色,它就不起作用,你必须写 0xff0000
才能工作,有没有办法让 ff0000
在没有 0x
的情况下工作?这是我的代码:
async def embed(ctx, *, content: str):
title, description, color = content.split('|')
embed = discord.Embed(title=title, description=description, color=int(color, 0))
await ctx.send(embed=embed)
如有任何帮助,我们将不胜感激。
您可以简单地将颜色 (ff0000
) 转换为以 16 为底数的 int
async def embed(ctx, *, content: str):
title, description, color = content.split("|")
embed = discord.Embed(title=title, description=description, colour=int(color, 16))
所以我写了这个发送嵌入消息的代码,如果你写000000
它会使嵌入变成黑色,但是如果你写ff0000
红色,它就不起作用,你必须写 0xff0000
才能工作,有没有办法让 ff0000
在没有 0x
的情况下工作?这是我的代码:
async def embed(ctx, *, content: str):
title, description, color = content.split('|')
embed = discord.Embed(title=title, description=description, color=int(color, 0))
await ctx.send(embed=embed)
如有任何帮助,我们将不胜感激。
您可以简单地将颜色 (ff0000
) 转换为以 16 为底数的 int
async def embed(ctx, *, content: str):
title, description, color = content.split("|")
embed = discord.Embed(title=title, description=description, colour=int(color, 16))