mirror of
https://github.com/Noratrieb/widetom.git
synced 2026-01-14 08:55:02 +01:00
gamer 2
This commit is contained in:
parent
bb2c954418
commit
387f6ff587
3 changed files with 11 additions and 32 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub async fn normal_message(ctx: &Context, msg: &Message) {
|
|||
let map = data
|
||||
.get_mut::<LastMessageInChannel>()
|
||||
.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();
|
||||
|
||||
|
|
@ -33,13 +33,13 @@ pub async fn normal_message(ctx: &Context, msg: &Message) {
|
|||
.as_str()
|
||||
.parse::<u32>()
|
||||
.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() {
|
||||
if msg.content.to_lowercase() == *trigger {
|
||||
reply(answer, &msg, &ctx).await;
|
||||
reply(answer, msg, ctx).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue