我想让机器人发送嵌入式消息时,颜色是随机的。这是我的代码:
colors = ['0xFFE4E1', '0x00FF7F', '0xD8BFD8', '0xDC143C', '0xFF4500', '0xDEB887', '0xADFF2F', '0x800000', '0x4682B4', '0x006400', '0x808080', '0xA0522D', '0xF08080', '0xC71585', '0xFFB6C1', '0x00CED1']
@client.command(help='Shares a meme')
async def meme(ctx):
subreddit = reddit.subreddit("dankmemes")
all_subs = []
top = subreddit.top(limit = 75)
for submission in top:
all_subs.append(submission)
random_sub = random.choice(all_subs)
name = random_sub.title
url = random_sub.url
em = discord.Embed(title = name, color = random.choice(colors))
em.set_image(url = url)
await ctx.send(embed = em)
我遇到了这个错误:TypeError: 预期 discord.Colour、int 或 Embed.Empty,但实际收到的是 str。
不确定如何修复它,有什么提示吗?
discord.Color
类的默认输入,所以它可以正常工作。 - Aaron