This commit is contained in:
nora 2025-11-01 15:25:58 +01:00
parent bb2c954418
commit 387f6ff587
3 changed files with 11 additions and 32 deletions

View file

@ -11,9 +11,7 @@ use serenity::framework::standard::{
use serenity::model::channel::Message; use serenity::model::channel::Message;
use serenity::model::id::UserId; use serenity::model::id::UserId;
use serenity::utils::{content_safe, ContentSafeOptions}; use serenity::utils::{content_safe, ContentSafeOptions};
use uwuifier::uwuify_str_sse;
use crate::general::reply;
use crate::{Config, LastMessageInChannel}; use crate::{Config, LastMessageInChannel};
#[group] #[group]
@ -26,12 +24,6 @@ struct General;
#[description = "meme commands"] #[description = "meme commands"]
struct Meme; struct Meme;
#[group]
#[commands(shutdown)]
#[owners_only]
#[description = "bot admin commands"]
struct Admin;
#[command] #[command]
#[description("lists all the commands")] #[description("lists all the commands")]
async fn list(ctx: &Context, msg: &Message, _: Args) -> CommandResult { 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) .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.delete(&ctx.http).await?;
msg.channel_id.say(&ctx.http, &content).await?; msg.channel_id.say(&ctx.http, &content).await?;
Ok(()) 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")] #[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 { async fn uwuify(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
if let Some(parent) = &msg.referenced_message { 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?; msg.channel_id.say(&ctx.http, uwu).await?;
} else if args.is_empty() { } else if args.is_empty() {
let mut data = ctx.data.write().await; 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); let old_message = map.get(&msg.channel_id);
match old_message { match old_message {
Some(s) => { Some(s) => {
let uwu = uwuify_str_sse(s); let uwu = uwuifier::uwuify_str_sse(s);
msg.channel_id.say(&ctx.http, uwu).await?; msg.channel_id.say(&ctx.http, uwu).await?;
} }
None => { None => {
@ -96,24 +88,12 @@ async fn uwuify(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
} }
} }
} else { } else {
let uwu = uwuify_str_sse(args.rest()); let uwu = uwuifier::uwuify_str_sse(args.rest());
msg.channel_id.say(&ctx.http, uwu).await?; msg.channel_id.say(&ctx.http, uwu).await?;
} }
Ok(()) 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] #[command]
#[description("display a random answer from the xp support applications")] #[description("display a random answer from the xp support applications")]
async fn xp(ctx: &Context, msg: &Message, _: Args) -> CommandResult { async fn xp(ctx: &Context, msg: &Message, _: Args) -> CommandResult {

View file

@ -13,7 +13,7 @@ pub async fn normal_message(ctx: &Context, msg: &Message) {
let map = data let map = data
.get_mut::<LastMessageInChannel>() .get_mut::<LastMessageInChannel>()
.expect("LastMessageInChannel not found"); .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::<Config>().unwrap(); let config = data.get::<Config>().unwrap();
@ -33,13 +33,13 @@ pub async fn normal_message(ctx: &Context, msg: &Message) {
.as_str() .as_str()
.parse::<u32>() .parse::<u32>()
.expect("matched regex, so it is valid"); .expect("matched regex, so it is valid");
reply(&*format!("<https://nhentai.net/g/{}/>", number), &msg, &ctx).await; reply(&format!("<https://nhentai.net/g/{}/>", number), msg, ctx).await;
} }
} }
for (trigger, answer) in config.responses.iter() { for (trigger, answer) in config.responses.iter() {
if msg.content.to_lowercase() == *trigger { if msg.content.to_lowercase() == *trigger {
reply(answer, &msg, &ctx).await; reply(answer, msg, ctx).await;
} }
} }

View file

@ -12,7 +12,7 @@ use serenity::http::Http;
use serenity::model::id::{ChannelId, UserId}; use serenity::model::id::{ChannelId, UserId};
use serenity::{async_trait, model::gateway::Ready, prelude::*}; 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; use crate::general::normal_message;
mod commands; 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 = fs::read_to_string(token_path).expect("Expected bot token in file 'bot_token'");
let token = token.trim(); let token = token.trim();
let http = Http::new(&token); let http = Http::new(token);
http.get_current_application_info() http.get_current_application_info()
.await .await
@ -87,8 +87,7 @@ async fn main() {
.normal_message(normal_message) .normal_message(normal_message)
.help(&MY_HELP) .help(&MY_HELP)
.group(&GENERAL_GROUP) .group(&GENERAL_GROUP)
.group(&MEME_GROUP) .group(&MEME_GROUP);
.group(&ADMIN_GROUP);
framework.configure( framework.configure(
Configuration::new() Configuration::new()
.with_whitespace(false) .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. // We don't really need all intents, but this is a small bot so we don't care.
let intents = GatewayIntents::all(); let intents = GatewayIntents::all();
let mut client = Client::builder(&token, intents) let mut client = Client::builder(token, intents)
.event_handler(Handler) .event_handler(Handler)
.framework(framework) .framework(framework)
.await .await