@client.command(pass_context = True)
async def getalt(ctx):
msg = ["gabrielwarren2000@gmail.com:Cyber123", "leandroriveros123@gmail.com:culillo123", "albesi8@msn.com:Albakortoci1", "dryden6@yahoo.ca:toysale22", "nichlas00100@gmail.com:nich918273645", "lodevanveen@gmail.com:Lodelode1", "kylefielding2011@gmail.com:emolover123", "rubbst3in@gmail.com:rube541632789mk", "jasonfryckman@ymail.com:fryckman22", "NickSaya1@hotmail.com:blackout541", "devinquan@yahoo.com:ploopy101"]
await client.send_message(ctx.message.author, random.choice(msg))
await client.send_message(ctx.message.channel, "Alt Has Been Seen To Your DMs")
await client.purge_from(ctx.message.channel, limit=2)
await client.send_message(ctx.message.author, "Please Wait 30 Seconds Before Using This Command Again.")
I want to set a 30 sec cooldown for this command.
You should decorate your command with
@commands.cooldown(1, 30, commands.BucketType.user)
This will add a ratelimit of 1 use per 30 seconds per user. docs, example
You can change the BucketType to default, channel or server to create a global, channel or server ratelimit instead, but you can only have 1 cooldown on a command.
This will also cause a CommandOnCooldown exception in on_command_error
来源:https://stackoverflow.com/questions/46087253/cooldown-for-command-on-discord-bot-python