Percent + fill commands added
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

This commit is contained in:
haruyuumei 2024-04-15 13:57:39 -03:00
parent 027c03ab1e
commit 2fb6c8f3b9

View file

@ -93,7 +93,87 @@ pub async fn init(mgr: Arc<ModulesManager>) {
};
the8ball.add_to_modmgr(Arc::clone(&mgr)).await;
let percent:BotCommand = BotCommand{
module:BotModule(String::from("percent")),
command:String::from("%"),
alias:vec![],
exec_body: actions_util::asyncbox(percentage),
help: String::from("Percent Help"),
required_roles: vec![
BotAdmin,
Broadcaster,
Mod(OF_CMD_CHANNEL),
VIP(OF_CMD_CHANNEL),
Chatter
]
};
percent.add_to_modmgr(Arc::clone(&mgr)).await;
let filler: BotCommand = BotCommand{
module:BotModule(String::from("filler")),
command:String::from("fill"),
alias:vec![String::from("Fill")],
exec_body:actions_util::asyncbox(fill),
help:String::from("fill Help"),
required_roles: vec![
BotAdmin,
Broadcaster,
Mod(OF_CMD_CHANNEL),
VIP(OF_CMD_CHANNEL)
]
};
filler.add_to_modmgr(Arc::clone(&mgr)).await;
}
///Fill command, can be used to make the bot reply with a certain quantity of the same message
///
/// only works with `(prefix)fill` `word` `quantity`
///
///
async fn fill(params : ExecBodyParams)
{
let usermessage = usermsg(&params);
let quantity = usermessage.get(&2).unwrap();
let mut botreply = String::new();
for _i in 0..quantity.parse::<i32>().unwrap(){
botreply.push_str(usermessage.get(&1).unwrap().trim());
botreply.push(' ');
}
let bot = Arc::clone(&params.bot);
let botlock = bot.read().await;
botlock
.botmgrs
.chat
.say_in_reply(
Channel(params.clone().msg.channel_login().to_string()),
botreply.clone(),
params.clone()
).await;
}
///Percentage is a function that returns a ramdom %
///
async fn percentage (params : ExecBodyParams)
{
let mut _botreply = String::new();
let rng = thread_rng().gen_range(0..100);
let rng_string = rng.to_string();
_botreply = rng_string + "%";
let bot = Arc::clone(&params.bot);
let botlock = bot.read().await;
botlock
.botmgrs
.chat
.say_in_reply(
Channel(params.clone().msg.channel_login().to_string()),
_botreply.clone(),
params.clone()
).await;
}
@ -132,8 +212,6 @@ async fn the8ball(params : ExecBodyParams)
let randchoice = thread_rng().gen_range(0..vecanswears.len());
let ballmessage = &vecanswears[randchoice];
let bot = Arc::clone(&params.bot);
let botlock = bot.read().await;
botlock