1

How do you do it, that if someone uses a command, a timer starts and does something if a user answers in a in the given time? Like someone does "!shoot @user#0000" and the tagged user has to answer with "!dodge" in under 10 seconds or he dies

1 Answers1

2

You could use the wait_for method:

@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!")

Chris
  • 1,206
  • 2
  • 15
  • 35