python - Looking for a way to code a command cooldown for Discord Bot -


i using python.

here sample command:

@client.command(pass_context=true) async def enablesentience(ctx):     await client.say(":desktop: | user not have sufficient permissions.") 

when command 'enablesentience' triggered, bot says in chat:

:desktop: | user not have sufficient permissions.

what looking way add cooldown command, person may use command once every how many seconds. if command attempted while cooldown active, want bot in chat remaining cooldown time.

i have attempted:

@client.command(pass_context=true) @commands.cooldown(1, 30, commands.server.user) async def enablesentience(ctx):     await client.say(":desktop: | user not have sufficient permissions.") 

and

async def cooldown(1, 5, type=server.default)  @client.command(pass_context=true) async def enablesentience(ctx):     await client.say(":desktop: | user not have sufficient permissions.") 

which gave "'command' object has no attribute 'cooldown'" , syntax errors, respectively.

any appreciated, , thank in advance.

your first attempt right -- need specify buckettype use, instead of "commands.server.user", so:

@commands.cooldown(1, 30, commands.buckettype.user) 

there multiple buckets can choose from. they're in source code here. (default means global.)


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -