Discord.Py: Add a cooldown on CommandOnCooldown error event

Viewed 414

So i've added @commands.cooldown(1, 10, commands.BucketType.user) to my bot to try and stop people from spamming it. I've set the error message like:

async def on_command_error(ctx, error):
   if isinstance(error, commands.CommandOnCooldown):

       await ctx.send(f'This command is not ready to use, try again in  %.2f seconds' % error.retry_after)
       return

But my question is, how would i make it so it only sends once? Because people can spam the command that activates the cooldown, and they can still make the bot spam the on_cooldown message.

So my question is: How can I make the on_cooldown message have a cooldown on itself

Any help would be very appreciated

1 Answers

for making such cooldowns i prefer using asyncio.

Try using asyncio.sleep() it might help you for getting a certain cooldown without getting bot spammed.

Related