I am trying to add a cooldown to a Discord bot command in python. I want it so that people can only use the command once per minute and if they try to use it more it will send them a message with how much time is left. Here is my current code:
@client.command(pass_context=True)
@commands.cooldown(1, 60, commands.BucketType.user)
async def work(context):
Can you please tell me what is wrong with this?
You are facing following error:
@client.command(pass_context=True)
@commands.cooldown(1, 60, commands.BucketType.user)
async def work(context):
with error name 'commands' is not definied
means you need to import additional module.
from discord.ext import commands
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.