diff --git a/macros/Cargo.lock b/macros/Cargo.lock index de9713ee6919..c8eb1734ae78 100644 --- a/macros/Cargo.lock +++ b/macros/Cargo.lock @@ -51,7 +51,7 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "poise_macros" -version = "0.5.7" +version = "0.6.1" dependencies = [ "darling", "proc-macro2", diff --git a/macros/src/command/mod.rs b/macros/src/command/mod.rs index 8c7f8bbd6136..5b1decf89714 100644 --- a/macros/src/command/mod.rs +++ b/macros/src/command/mod.rs @@ -49,6 +49,8 @@ pub struct CommandArgs { category: Option, custom_data: Option, + manual_cooldowns: Option, + // In seconds global_cooldown: Option, user_cooldown: Option, @@ -280,6 +282,7 @@ fn generate_command(mut inv: Invocation) -> Result Result Result Result>::to_action(|ctx, value| { Box::pin(async move { - if !ctx.framework.options.manual_cooldowns { + let is_framework_cooldown = !ctx.command.manual_cooldowns + .unwrap_or_else(|| ctx.framework.options.manual_cooldowns); + + if is_framework_cooldown { ctx.command.cooldowns.lock().unwrap().start_cooldown(ctx.cooldown_context()); } diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 5316651af233..670806501ffd 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -67,7 +67,7 @@ for example for command-specific help (i.e. `~help command_name`). Escape newlin - `reuse_response`: After the first response, post subsequent responses as edits to the initial message (prefix only) ## Cooldown - +- `manual_cooldowns`: Allows overriding the framework's built-in cooldowns tracking without affecting other commands. - `global_cooldown`: Minimum duration in seconds between invocations, globally - `user_cooldown`: Minimum duration in seconds between invocations, per user - `guild_cooldown`: Minimum duration in seconds between invocations, per guild diff --git a/src/structs/command.rs b/src/structs/command.rs index 453a4840151f..9a300b3f9369 100644 --- a/src/structs/command.rs +++ b/src/structs/command.rs @@ -58,6 +58,11 @@ pub struct Command { /// Multiline description with detailed usage instructions. Displayed in the command specific /// help: `~help command_name` pub help_text: Option, + /// if `true`, disables automatic cooldown handling before this commands invocation. + /// + /// Will override [`crate::FrameworkOptions::manual_cooldowns`] allowing manual cooldowns + /// on select commands. + pub manual_cooldowns: Option, /// Handles command cooldowns. Mainly for framework internal use pub cooldowns: std::sync::Mutex, /// Configuration for the [`crate::CooldownTracker`]