Created
October 17, 2020 20:57
-
-
Save 15696/98ea4724593cd769650f4190a7200e2f to your computer and use it in GitHub Desktop.
simple cooldowns and cooldown handlers in discord.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@client.event | |
async def on_command_error(ctx, error): | |
if isinstance(error, commands.CommandOnCooldown): | |
await ctx.send(f"{round(error.retry_after, 2)} seconds left") | |
@client.command() | |
@commands.cooldown(1, 5, commands.BucketType.user) | |
async def command(ctx): | |
await ctx.send("command output") | |
# note that commands.cooldown is not really meant for cooldowns over an hour | |
# and restarting your bot will mess up all the cooldowns currently in place | |
# 1, 5, BucketType.user means individual users can use this command 1 time every 5 seconds | |
# check the api reference for more types of buckettypes: | |
# https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.BucketType |
says "cooldown is not callable" any help
thx mate
thx
gonna use this as well! wink
nice lol
my shd be saying cooldown is not callable
Hello @koer2fine, this gist is extremely outdated. I would recommend you not use this as this was made 3 years ago.
Hello @koer2fine, this gist is extremely outdated. I would recommend you not use this as this was made 3 years ago.
@koer2fine
it is, but the idea is the same, you should get the latest knowledge from the docs of your preferred module!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice lol