Percent + fill commands added
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
This commit is contained in:
parent
027c03ab1e
commit
2fb6c8f3b9
1 changed files with 80 additions and 2 deletions
|
@ -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(¶ms);
|
||||
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(¶ms.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(¶ms.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(¶ms.bot);
|
||||
let botlock = bot.read().await;
|
||||
botlock
|
||||
|
|
Loading…
Reference in a new issue