DSharpPlus
DSharpPlus copied to clipboard
Ported CommandsNext cooldown attribute to Slash Commands
Closes #1374. Untested.
The attribute for this was lazily copied as CooldownAttribute rather than the expected SlashCooldownAttribute, as well as CooldownBucketType.
This lead to me having to avoid ambiguity by doing the following:
[DSharpPlus.SlashCommands.Attributes.Cooldown(1, 10, DSharpPlus.SlashCommands.Attributes.CooldownBucketType.User)]
Even doing that, it does not work.
I traced through the stack and found out that the this._buckets was being recreated every time the command is called, likely from the following line:
https://github.com/DSharpPlus/DSharpPlus/blob/f1d2fc8f58cca77e7a23502f9768a6215b85de14/DSharpPlus.SlashCommands/Built-in%20Checks/SlashCooldownAttribute.cs#L69
I tried fixing this myself for a while, but it seems I'm in over my head so I don't have any solution for it. this._buckets is still empty every time the ExecuteCheckAsync is called. It contains no values and thus a new bucket is created each call, resulting in nothing happening.
Yeah the user is expected to handle that failed check
This PR disregards different commands entirely;
Setting a command with a cooldown i.e with [SlashCooldown(1, 20, SlashCooldownBucketType.Guild)] then using another command with the same cooldown within the time span of the first command will fail the check. Is this intended?
Uh oh. Could you create an issue with a repro?