DSharpPlus icon indicating copy to clipboard operation
DSharpPlus copied to clipboard

Ported CommandsNext cooldown attribute to Slash Commands

Open OoLunar opened this issue 3 years ago • 2 comments

Closes #1374. Untested.

OoLunar avatar Aug 10 '22 18:08 OoLunar

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.

Erisa avatar Aug 10 '22 20:08 Erisa

Yeah the user is expected to handle that failed check

OoLunar avatar Aug 10 '22 20:08 OoLunar

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?

Nenkai avatar Aug 15 '22 19:08 Nenkai

Uh oh. Could you create an issue with a repro?

OoLunar avatar Aug 15 '22 19:08 OoLunar