【发布时间】:2021-07-24 20:59:58
【问题描述】:
所以我制作了这段代码,用户可以在其中选择自己的嵌入颜色,但如果他们嵌入错误的内容,它会搞砸整个事情,他们需要重做,如果他们不这样做,有没有办法做到这一点? t 响应或输入不正确的十六进制代码,它将自动转到十六进制颜色 FF00EC。
@client.command(aliases=['say'])
@commands.has_permissions(manage_messages=True)
async def embed(ctx):
questions = ["Which should be the tile of the embed?",
"What should be the description?",
"What is the color of the embed? This should be a hex color. Note, Must put a `Correct` Hex color or you will need to redo this also leave out the #."]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await client.wait_for('message', timeout=30, check=check)
except asyncio.TimeoutError:
await ctx.send('You did not answer in time. Please do it under 30 seconds next time.')
return
else:
answers.append(msg.content)
embedcolor = answers[2]
embed = discord.Embed(description=answers[1], title=answers[0], colour=int(embedcolor, 16))
await ctx.send(embed=embed)
这是我的代码
【问题讨论】: