-
-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible bug in cooldowns #2057
Comments
All commands have the pycord/discord/commands/core.py Line 198 in 4364260
Odd logic, but not a bug (and in my personal experience, cooldowns work fine without max_concurrency ).
|
No. pycord/discord/commands/core.py Lines 1116 to 1154 in a09e728
It doesn't have max_concurrency and cooldown attributes. If we add those to pycord/discord/commands/core.py Lines 297 to 308 in a09e728
|
This is true, but it's irrelevant: you can't use a group on its own, so it doesn't have the attributes - neither have you ever been able to add cooldowns to groups in their init, and you can't create them with a decorator either. All of its subcommands still have |
Yes I'm aware. But you could accept them through the kwrags for SlashCommandGroup init. I added this to the init- class SlashCommandGroup(ApplicationCommand):
...
def __init__(...):
...
from ..ext.commands.cooldowns import BucketType, CooldownMapping, MaxConcurrency
cooldown = getattr(self, "__commands_cooldown__", kwargs.get("cooldown"))
if cooldown is None:
buckets = CooldownMapping(cooldown, BucketType.default)
elif isinstance(cooldown, CooldownMapping):
buckets = cooldown
else:
raise TypeError(
"Cooldown must be a an instance of CooldownMapping or None."
)
self._buckets: CooldownMapping = buckets
max_concurrency = getattr(
self, "__commands_max_concurrency__", kwargs.get("max_concurrency")
)
self._max_concurrency: MaxConcurrency | None = max_concurrency and changed the logic to if self._max_concurrency:
# For this application, context can be duck-typed as a Message
await self._max_concurrency.acquire(ctx) # type: ignore # ctx instead of non-existent message
try:
self._prepare_cooldowns(ctx)
await self.call_before_hooks(ctx)
except:
if self._max_concurrency:
await self._max_concurrency.release(ctx) # type: ignore # ctx instead of non-existent message
raise Didn't face issues in my limited scope of testing. If you want to read those changes in a better way, check out my commit from when I was trying stuff out. Ignore the untested fix for #2058 |
That's fair, my point was that this isn't a bug; it's a feature request. Just throw in a |
Oh lol alright. |
It might be that cooldowns and before_invoke would never run if you don't have max concurrency set for slash commands
pycord/discord/commands/core.py
Lines 297 to 308 in a09e728
Reported by @Om1609
The text was updated successfully, but these errors were encountered: