Custom Commands homeCustom Commands
  • Blog
  • Privacy
  • Premium
  • Support
Back to blog
// blog

Conditional cooldown for debugging custom commands

Want to have different cooldown for different user groups?

Md Shahriyar Alam

2 years ago

·1 min read

By utilizing the new has_permission or has_any_permission we can have conditional cooldowns in a command.

Lets say we want a 10 seconds cooldown for administrators and 1 minute cooldown for other users. We can use the has_permission function.

Code

py
if has_permission(user, "administrator"):
    cooldown("10 seconds", user.id)
else:
    cooldown("1 minutes", user.id)

Using this code in pre-hook will allow admins to use the command every 10 seconds, but other users will have a 1 minute cooldown.

If you want no cooldown for admins you can also do that easily by using the code below.

py
if not has_permission(user, "administrator"):
    cooldown("1 minutes", user.id)

This code will check if the user dont have the administrator permission, he will have 1 minute cooldown, Otherwise no cooldown.

Possibilities are endless. You just have to think. 🚀

Loading comments…

{}

Need help?

Have a question, a suggestion, or stuck on something? Reach out — we're happy to help.

DiscordJoin support server
Custom CommandsCustom Commands

The #1 custom commands Discord bot — build commands, events and databases with zero boilerplate.

Links

HomeBlogPrivacySupport

Contact

[email protected]

2 Frederick StreetLondon, WC1X 0ND

{ / } custom commands

© WEiRDSOFT LTD. All rights reserved.