question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cooldown is not applied on .sub_command()

See original GitHub issue

Summary

Сommand.cooldown() does not change the cooldown for specific slash commands

Reproduction Steps

  1. Create any slash command with command.cooldown()
  2. Create a sub command with any cooldown
  3. Run code

Minimal Reproducible Code

@commands.slash_command()
@commands.cooldown(1, 100)
    async def parent(self, inter):...

@parent.sub_command()
  async def sub_without_cooldown(self, inter):
      # something...

@parent.sub_command()
@commands.cooldown(1, 150)
   async def sub_example(self, inter):
        # something...

Expected Results

Sub_without_cooldown command and other sub commands will have cooldown specified in parent. Sub_example will have another cooldown

Actual Results

Sub_example has the same cooldown as parent

Intents

all

System Information

Disnake: 2.5.0a Python 3.10.1 Windows 10

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

I also tried to use dynamic_cooldown but it also doesn’t work with subcommands

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
toolifelesstocodecommented, Apr 20, 2022

You are very welcome! Please close the issue if your problem has been solved 😃

1reaction
Xemaycommented, Apr 20, 2022

Hello there, IIRC, cooldowns have a type= parameter that you can use with commands.BucketType. The last time someone had the same problem, this worked for them and it works for me too.

Hello. unfortunately I just tried it and it didn’t work. I used the same and different BucketType in parent and sub_example but it didn’t help. Could you show me an example with code?

Something like

@commands.slash_command()
async def le_cmd(self, inter: CommandInteraction):
    ...

@le_cmd.sub_command()
@commands.cooldown(1, 40, commands.BucketType.user)
async def cmd_cooldown(self, inter: CommandInteraction):
    # insert stuff here

But also note that on the code that you sent, cooldowns can’t work on parent commands, as you possibly know that parent commands will not show if you have subcommands. Ref: image

Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Discord.js | Command Cooldown is set but not working
Inside of your message.js , you probably confused command with the exported command object (from help.js for example).
Read more >
Command | Eris 0.17.1 - Abal.moe
An array of channel IDs representing channels that are not affected by cooldowns. Number of times to return a message when the command...
Read more >
discord.commands.core - Pycord v2.3 Documentation
If this is ``0.0`` then the command isn't on cooldown. """ if self._buckets.valid: bucket = self._buckets.get_bucket(ctx) current = utcnow().timestamp() ...
Read more >
API Reference - nextcord
Adds a Command into the internal list of commands. This is usually not called, instead the command() or group() shortcut decorators are used...
Read more >
Interactions API Reference - discord.py - Read the Docs
A dictionary that can be used to store extraneous data for use during interaction processing. The library will not touch any values or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found