diff --git a/src/commands.rs b/src/commands.rs index b42a609..e87f9b1 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -11,9 +11,7 @@ use serenity::framework::standard::{ use serenity::model::channel::Message; use serenity::model::id::UserId; use serenity::utils::{content_safe, ContentSafeOptions}; -use uwuifier::uwuify_str_sse; -use crate::general::reply; use crate::{Config, LastMessageInChannel}; #[group] @@ -26,12 +24,6 @@ struct General; #[description = "meme commands"] struct Meme; -#[group] -#[commands(shutdown)] -#[owners_only] -#[description = "bot admin commands"] -struct Admin; - #[command] #[description("lists all the commands")] async fn list(ctx: &Context, msg: &Message, _: Args) -> CommandResult { @@ -66,7 +58,7 @@ async fn say(ctx: &Context, msg: &Message, args: Args) -> CommandResult { .clean_role(false) }; - let content = content_safe(&ctx.cache, &args.rest(), &settings, &[]); + let content = content_safe(&ctx.cache, args.rest(), &settings, &[]); msg.delete(&ctx.http).await?; msg.channel_id.say(&ctx.http, &content).await?; Ok(()) @@ -76,7 +68,7 @@ async fn say(ctx: &Context, msg: &Message, args: Args) -> CommandResult { #[description("uwuifies the arguments, or the last message in the channel if no args are supplied")] async fn uwuify(ctx: &Context, msg: &Message, args: Args) -> CommandResult { if let Some(parent) = &msg.referenced_message { - let uwu = uwuify_str_sse(&*parent.content); + let uwu = uwuifier::uwuify_str_sse(&parent.content); msg.channel_id.say(&ctx.http, uwu).await?; } else if args.is_empty() { let mut data = ctx.data.write().await; @@ -86,7 +78,7 @@ async fn uwuify(ctx: &Context, msg: &Message, args: Args) -> CommandResult { let old_message = map.get(&msg.channel_id); match old_message { Some(s) => { - let uwu = uwuify_str_sse(s); + let uwu = uwuifier::uwuify_str_sse(s); msg.channel_id.say(&ctx.http, uwu).await?; } None => { @@ -96,24 +88,12 @@ async fn uwuify(ctx: &Context, msg: &Message, args: Args) -> CommandResult { } } } else { - let uwu = uwuify_str_sse(args.rest()); + let uwu = uwuifier::uwuify_str_sse(args.rest()); msg.channel_id.say(&ctx.http, uwu).await?; } Ok(()) } -#[command] -#[description("end tom")] -async fn shutdown(ctx: &Context, msg: &Message, _: Args) -> CommandResult { - reply( - "<:tom:811324632082415626> bye <:tom:811324632082415626>", - &msg, - &ctx, - ) - .await; - std::process::exit(0); -} - #[command] #[description("display a random answer from the xp support applications")] async fn xp(ctx: &Context, msg: &Message, _: Args) -> CommandResult { diff --git a/src/general.rs b/src/general.rs index 84c293f..9ee90c3 100644 --- a/src/general.rs +++ b/src/general.rs @@ -13,7 +13,7 @@ pub async fn normal_message(ctx: &Context, msg: &Message) { let map = data .get_mut::() .expect("LastMessageInChannel not found"); - map.insert(msg.channel_id.clone(), msg.content.clone()); + map.insert(msg.channel_id, msg.content.clone()); let config = data.get::().unwrap(); @@ -33,13 +33,13 @@ pub async fn normal_message(ctx: &Context, msg: &Message) { .as_str() .parse::() .expect("matched regex, so it is valid"); - reply(&*format!("", number), &msg, &ctx).await; + reply(&format!("", number), msg, ctx).await; } } for (trigger, answer) in config.responses.iter() { if msg.content.to_lowercase() == *trigger { - reply(answer, &msg, &ctx).await; + reply(answer, msg, ctx).await; } } diff --git a/src/main.rs b/src/main.rs index 73c0013..240287b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use serenity::http::Http; use serenity::model::id::{ChannelId, UserId}; use serenity::{async_trait, model::gateway::Ready, prelude::*}; -use crate::commands::{ADMIN_GROUP, GENERAL_GROUP, MEME_GROUP, MY_HELP}; +use crate::commands::{GENERAL_GROUP, MEME_GROUP, MY_HELP}; use crate::general::normal_message; mod commands; @@ -67,7 +67,7 @@ async fn main() { let token = fs::read_to_string(token_path).expect("Expected bot token in file 'bot_token'"); let token = token.trim(); - let http = Http::new(&token); + let http = Http::new(token); http.get_current_application_info() .await @@ -87,8 +87,7 @@ async fn main() { .normal_message(normal_message) .help(&MY_HELP) .group(&GENERAL_GROUP) - .group(&MEME_GROUP) - .group(&ADMIN_GROUP); + .group(&MEME_GROUP); framework.configure( Configuration::new() .with_whitespace(false) @@ -100,7 +99,7 @@ async fn main() { // We don't really need all intents, but this is a small bot so we don't care. let intents = GatewayIntents::all(); - let mut client = Client::builder(&token, intents) + let mut client = Client::builder(token, intents) .event_handler(Handler) .framework(framework) .await