diff --git a/src/commands/bots.rs b/src/commands/bots.rs new file mode 100644 index 0000000..0557924 --- /dev/null +++ b/src/commands/bots.rs @@ -0,0 +1,17 @@ +use crate::{Context, Error}; +use crate::commands::{command_helper, helpstart}; +use std::string::String; + +#[poise::command(slash_command)] +pub(crate) async fn bots( + ctx: Context<'_>, + + #[min = 0_u8] + #[description = "default: 0"] + bots: u8 +) -> Result<(), Error> { + helpstart::set_bots_available(bots).await; + + let reply = format!("{} bots are now registered as available", bots).to_string(); + command_helper::send(ctx, reply).await +} \ No newline at end of file diff --git a/src/commands/helpstart.rs b/src/commands/helpstart.rs index bd89c72..e7b9c97 100644 --- a/src/commands/helpstart.rs +++ b/src/commands/helpstart.rs @@ -1,6 +1,8 @@ use crate::{Context, Error}; use crate::commands::command_helper; +static mut BOTS_AVAILABLE: u8 = 0; + #[poise::command(slash_command)] pub(crate) async fn helpstart( ctx: Context<'_>, @@ -11,17 +13,28 @@ pub(crate) async fn helpstart( #[rename = "needed"] needed_players: u8 ) -> Result<(), Error> { - if let Some(value) = command_helper::cooldown( - &ctx, - 1200, - 600 - ) { - return value; - } - let reply = format!( - "<@&1008075054971621448>\nneed: {}" - ,needed_players - ); + let bots = unsafe { BOTS_AVAILABLE }; + + let reply= if bots >= needed_players { + "Bots available. Please use the Zombies Helpstart v2 Bot in the bot-commands channel instead.".to_string() + } else { + if let Some(value) = command_helper::cooldown( + &ctx, + 1200, + 600 + ) { + return value; + }; + format!( + "<@&1008075054971621448>\nneed: {}" + , (needed_players - bots) + ) + }; command_helper::send(ctx, reply).await +} +pub async fn set_bots_available(bots: u8) { + unsafe { + BOTS_AVAILABLE = bots; + } } \ No newline at end of file diff --git a/src/commands/mod.rs b/src/commands/mod.rs index bef877a..c8bc514 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,5 +1,6 @@ pub(crate) mod lfg; pub(crate) mod xd; pub(crate) mod helpstart; -mod command_helper; +pub(crate) mod command_helper; +pub(crate) mod bots; diff --git a/src/main.rs b/src/main.rs index b56c41d..b37926d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,8 @@ async fn poise( commands: vec![ commands::lfg::lfg(), commands::xd::xd(), - commands::helpstart::helpstart() + commands::helpstart::helpstart(), + commands::bots::bots(), ], manual_cooldowns: true, prefix_options: poise::PrefixFrameworkOptions {