Search code examples
discorddiscord.py

Prevent commands during client.wait_for() discord.py


I've encountered a problem with client.wait_for().

while True:
      msg = await client.wait_for('message', check=lambda message: message.author == ctx.author)

While running an infinite loop, when I type in the same command, there is another "instance" of that command running.

Is there a way to prevent the usage of commands during the client.wait_for() response?

I tried with startswith('prefix') but It's not working, the commands execute anyway.


Solution

  • To limit the usage of ONE command so that it can to allow a certain number of invocations at the same time, use the decorator max_concurrency.