Custom this BotCommand #48

Merged
modulatingforce merged 12 commits from say-this-guy into master 2024-04-09 15:49:58 -04:00
Showing only changes of commit 72d4cf6d70 - Show all commits

View file

@ -6,25 +6,42 @@ use rand::Rng;
use std::sync::Arc;
use tokio::time::{sleep, Duration};
//use rand::Rng;
//using the env file to get bot prefix
use std::env;
use dotenv::dotenv;
//bot function
async fn tsg(params: ExecBodyParams) {
if params.msg.message_text == String::from("anime")
|| params.msg.message_text == String::from("Anime")
//Defining a var prefix to the prefix on the env file
dotenv().ok();
let prefix = env::var("prefix").unwrap();
/*
defining a text with the prefix + the command name (idk how to get the command)
so for now i'm typing the command
*/
let text = String::from(&prefix) + "This";
let text2 = String::from(&prefix) + "this";
//comparing the text sent with the text (prefix + command name)
if params.msg.message_text == text
|| params.msg.message_text == text2
{
let phrases: [String; 5] = [
"Aware oh no! Weebs...".to_string(),
"AYAYA I love anime Girls!!".to_string(),
"I love 2d Girls ILOST ".to_string(),
"UOOHHHHH!!! Anime Girlssss".to_string(),
"Anime girls u say? peepoShy ".to_string(),
let phrases: [String; 6] = [
"Clueless".to_string(),
"ICANT This guy....".to_string(),
"He is right tho".to_string(),
"KEKW true!".to_string(),
"OMEGALUL wth man...".to_string(),
"PepeLaugh El no sabe".to_string(),
modulatingforce marked this conversation as resolved
Review

We're getting an error here in ci/cd

error[E0061]: this method takes 4 arguments but 3 arguments were supplied
   --> src\custom\thisguy.rs:37:10
    |
37  |         .say_in_reply_to(&params.msg, a, params.clone())
    |          ^^^^^^^^^^^^^^^ -----------     -------------- an argument of type `std::string::String` is missing
    |                          |
    |                          expected `Channel`, found `&PrivmsgMessage`
    |
note: method defined here
   --> src\core\chat.rs:415:18
    |
415 |     pub async fn say_in_reply_to(
    |                  ^^^^^^^^^^^^^^^
416 |         &self,
417 |         destination_channel : Channel ,
    |         -----------------------------
418 |         reply_message_id : String ,
    |         -------------------------
419 |         outmsg: String ,
    |         --------------
420 |         params : ExecBodyParams)
    |         -----------------------
help: provide the argument
    |
37  |         .say_in_reply_to(/* core::botinstance::Channel */, a, /* std::string::String */, params.clone())
    |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Recommend this be adjusted to

.say_in_reply_to(&params.msg.channel_login(), &params.msg.message_id(),a, params.clone())
We're getting an error here in ci/cd ``` error[E0061]: this method takes 4 arguments but 3 arguments were supplied --> src\custom\thisguy.rs:37:10 | 37 | .say_in_reply_to(&params.msg, a, params.clone()) | ^^^^^^^^^^^^^^^ ----------- -------------- an argument of type `std::string::String` is missing | | | expected `Channel`, found `&PrivmsgMessage` | note: method defined here --> src\core\chat.rs:415:18 | 415 | pub async fn say_in_reply_to( | ^^^^^^^^^^^^^^^ 416 | &self, 417 | destination_channel : Channel , | ----------------------------- 418 | reply_message_id : String , | ------------------------- 419 | outmsg: String , | -------------- 420 | params : ExecBodyParams) | ----------------------- help: provide the argument | 37 | .say_in_reply_to(/* core::botinstance::Channel */, a, /* std::string::String */, params.clone()) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` --- Recommend this be adjusted to ```rust .say_in_reply_to(&params.msg.channel_login(), &params.msg.message_id(),a, params.clone()) ```
];
let r = rand::thread_rng().gen_range(0..=4);
let a = phrases[r].clone();
botlog::debug(
"Oh god I love anime Girls!!",
"This guy works!",
Some("modules > thisguy()".to_string()),
Some(&params.msg),
);
@ -39,16 +56,16 @@ async fn tsg(params: ExecBodyParams) {
.await;
sleep(Duration::from_secs_f64(0.5)).await;
}else {
println!("didn't type the proper command");
}
}
pub async fn init(mgr: &Arc<ModulesManager>) {
BotCommand {
module: BotModule(String::from("thisguy")),
command: String::from("anime"),
alias: vec![String::from("Anime")],
exec_body: actions_util::asyncbox(tesst),
command: String::from("thisguy"),
alias: vec![String::from("Thisguy")],
exec_body: actions_util::asyncbox(test),
help: String::from("test"),
required_roles: vec![BotAdmin],
}
@ -65,11 +82,46 @@ pub async fn init(mgr: &Arc<ModulesManager>) {
.await;
}
async fn tesst(params: ExecBodyParams) {
println!("tesst triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call
async fn test(params: ExecBodyParams) {
println!("Test triggered!"); // NOTE : This test function intends to print (e.g., to stdout) at fn call
botlog::debug(
"tesst triggered!",
"test triggered!",
Some("modules > tesst()".to_string()),
Some(&params.msg),
);
}
// just testing this area, not working atm
async fn replyer(params: ExecBodyParams)
{
/*
check if the command message was a reply
get reply message parent
reply to the parent
*/
//let reply_parent_message;
let reply_message: &String = &params.msg.message_text;
let my_reply:String = String::from("test");
//println!("{:?}",reply_parent_message);
println!("{}",reply_message);
botlog::debug(
"Oh god I love anime Girls!!",
Some("modules > thisguy()".to_string()),
Some(&params.msg),
);
let bot = Arc::clone(&params.bot);
let botlock = bot.read().await;
// uses chat.say_in_reply_to() for the bot controls for messages
botlock
.botmgrs
.chat
.say_in_reply_to(&params.msg, my_reply, params.clone())
.await;
sleep(Duration::from_secs_f64(0.5)).await;
}