【发布时间】:2021-05-17 03:42:12
【问题描述】:
我猜了discord bot中的角色游戏,(见下面的代码)。 我想为玩家添加 30 秒的超时响应,但我完全不知道该怎么做,有什么帮助吗?
@client.command()
async def game(ctx):
chosen_image = random.choice(embedlinks.bnhaLinks)
channel = ctx.channel
index = embedlinks.bnhaLinks.index(chosen_image)
embed = discord.Embed(color=0x999999)
embed.set_image(url=chosen_image)
embed.set_footer(text=f"You have 30 seconds to guess this MHA character")
await ctx.send(embed=embed)
def check(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
user_guess = (await client.wait_for('message', check=check)).content
if user_guess == embedlinks.bnhaChars[index]:
await ctx.send('Correct. Good job.')
elif user_guess is not embedlinks.bnhaChars[index]:
await ctx.send('Wrong. Start a new game.')```
【问题讨论】: