Slash Commands Cooldown
I've been wanting to implement a cool down for slash commands but from the DSharpPlus.SlashCommands.Attributes page in the docs it doesn't seem like it exists - are cooldown attributes not able to be implemented for slash commands or is this just a missing feature?
What's the recommended way to implement per-user cooldowns without a slash command attribute?
You may use TimeSpan Class to implement the per-user cooldowns.
To be honest, the DSharpPlus does not need to implement per-user cooldown attribute for Slash Commands, you may create your own attribute instead.
while that is a good point, DSharpPlus does provide a cooldown attribute in CommandsNext, so a SlashCommands cooldown attribute isn't unjustified per se.
You may use
TimeSpanClass to implement the per-user cooldowns. To be honest, the DSharpPlus does not need to implement per-user cooldown attribute for Slash Commands, you may create your own attribute instead.
@Poinet I'm still an unskilled programmer, would you mind elaborating?
I was thinking something like creating a MemberUse class which inherits from DiscordMember with a property that stores when the user last used a command. When a command is used they would be added to a list called usersUsingCommand and removed once the command has finished executing.
The problem I see with doing this is that an instance of MemberUse in the list won't be removed if code halts unexpectedly. This is why I'm really wanting a cooldown attribute because it makes it super easy and deals with this all for me.
If you need a reference for implementation, see https://github.com/DSharpPlus/DSharpPlus/blob/master/DSharpPlus.CommandsNext/Attributes/CooldownAttribute.cs.
I'm going to have to do it another way because that is beyond my level.
fortunately for you, #1375 aims to port the feature to slash commands.
Wow, that's great! Can I expect this to be out in a nightly release sometime soon?
Probably as soon as someone gets around to testing it.
Nightlies are created when a new commit to the master branch happens. They're done automatically by Github Actions and are usually downloadable from Nuget within 10 minutes
Thank you guys, much appreciated 👍