Answers for "cooldown discord.py"

1

how to make a cooldown in discord.py

from discord.ext.commands import cooldown, BucketType

@commands.cooldown(1, 3, commands.BucketType.user)
@client.command()
async def command_name(ctx):
	print('Eyy')

@command_name.error
async def command_name_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        em = discord.Embed(title=f"You are in cooldown",description=f"Try again in {error.retry_after:.2f}s.", color=discord.Color.orange())
        await ctx.send(embed=em)
Posted by: Guest on June-28-2021
1

is_on_cooldown discord.py

is_on_cooldown(Context)
'''
Context is the context for the command
is_on_cooldown returns a boolean operator of if the command mentioned is on cooldown.
You need to pass_context to use it
'''

EXAMPLE:
  
@client.command(pass_content=True)
async def notcool(ctx):
  for command in client.commands():
    await ctx.channel.send(ctx.is_on_cooldown(command))
    #This will send out the cooldown status of all the commands in the bot.
Posted by: Guest on September-20-2020
0

add cooldown to command discord.py

@commands.cooldown(1, 30, commands.BucketType.user)
Posted by: Guest on May-20-2021

Code answers related to "cooldown discord.py"

Browse Popular Code Answers by Language