Skip to content Skip to sidebar Skip to footer

How To Allow Only One Person At A Time To Use Discord Bot

So I have this line of code: async def on_message(message): if message.content == '!test': await asyncio.sleep(15) await message.channel.send('Hello world'!) If I want t

Solution 1:

If you want to make that only 1 person can use it at a time so you can add an if statement as I have added below:

occupied = False
@client.event
async def on_message(message):
    global occupied
    if not occupied:
        occupied = True
    elif occupied:
        await ctx.send("Someone is using command pls wait")
        return
    if message.content == "!test":
        await asyncio.sleep(15)
        await message.channel.send("Hello world"!)

I have added the if statement so if someone runs command var occupied will be true and then if someone else tries to run the command it will show someone is using it.


Post a Comment for "How To Allow Only One Person At A Time To Use Discord Bot"