执行命令时检查用户命令

没用_lol

你是怎么做的,如果有人使用命令,计时器启动并在用户在给定时间内回答时做一些事情?就像有人做“!shoot @user#0000”一样,被标记的用户必须在 10 秒内回答“!dodge”,否则他会死

安德烈

您可以使用以下wait_for 方法

@client.command(name = "shoot")
async def shoot_user(ctx, user: discord.Member):
   channel = ctx.channel
   def check(m):
        return m.content == '!dodge' and m.channel == channel and m.author == user
   try:
        await client.wait_for('message', check=check, timeout = 10.0)     
   except asyncio.TimeoutError:
        await channel.send(f"{user.mention} did not dodge in time!")
   else:
        await channel.send(f"{user.mention} dodged!")

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章