hstoggle -like command
This commit is contained in:
parent
8e7ea892f2
commit
e5fe7a5378
4 changed files with 45 additions and 13 deletions
17
src/commands/bots.rs
Normal file
17
src/commands/bots.rs
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
use crate::{Context, Error};
|
use crate::{Context, Error};
|
||||||
use crate::commands::command_helper;
|
use crate::commands::command_helper;
|
||||||
|
|
||||||
|
static mut BOTS_AVAILABLE: u8 = 0;
|
||||||
|
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
pub(crate) async fn helpstart(
|
pub(crate) async fn helpstart(
|
||||||
ctx: Context<'_>,
|
ctx: Context<'_>,
|
||||||
|
@ -11,17 +13,28 @@ pub(crate) async fn helpstart(
|
||||||
#[rename = "needed"]
|
#[rename = "needed"]
|
||||||
needed_players: u8
|
needed_players: u8
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
if let Some(value) = command_helper::cooldown(
|
let bots = unsafe { BOTS_AVAILABLE };
|
||||||
&ctx,
|
|
||||||
1200,
|
let reply= if bots >= needed_players {
|
||||||
600
|
"Bots available. Please use the Zombies Helpstart v2 Bot in the bot-commands channel instead.".to_string()
|
||||||
) {
|
} else {
|
||||||
return value;
|
if let Some(value) = command_helper::cooldown(
|
||||||
}
|
&ctx,
|
||||||
let reply = format!(
|
1200,
|
||||||
"<@&1008075054971621448>\nneed: {}"
|
600
|
||||||
,needed_players
|
) {
|
||||||
);
|
return value;
|
||||||
|
};
|
||||||
|
format!(
|
||||||
|
"<@&1008075054971621448>\nneed: {}"
|
||||||
|
, (needed_players - bots)
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
command_helper::send(ctx, reply).await
|
command_helper::send(ctx, reply).await
|
||||||
|
}
|
||||||
|
pub async fn set_bots_available(bots: u8) {
|
||||||
|
unsafe {
|
||||||
|
BOTS_AVAILABLE = bots;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
pub(crate) mod lfg;
|
pub(crate) mod lfg;
|
||||||
pub(crate) mod xd;
|
pub(crate) mod xd;
|
||||||
pub(crate) mod helpstart;
|
pub(crate) mod helpstart;
|
||||||
mod command_helper;
|
pub(crate) mod command_helper;
|
||||||
|
pub(crate) mod bots;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ async fn poise(
|
||||||
commands: vec![
|
commands: vec![
|
||||||
commands::lfg::lfg(),
|
commands::lfg::lfg(),
|
||||||
commands::xd::xd(),
|
commands::xd::xd(),
|
||||||
commands::helpstart::helpstart()
|
commands::helpstart::helpstart(),
|
||||||
|
commands::bots::bots(),
|
||||||
],
|
],
|
||||||
manual_cooldowns: true,
|
manual_cooldowns: true,
|
||||||
prefix_options: poise::PrefixFrameworkOptions {
|
prefix_options: poise::PrefixFrameworkOptions {
|
||||||
|
|
Loading…
Add table
Reference in a new issue