From 29bbe27bc2ed5b7b8de7914dfca8c79f0701f0af Mon Sep 17 00:00:00 2001 From: 1Kill2Steal <171241044+1Git2Clone@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:57:45 +0300 Subject: [PATCH] General, embed and level commands restructuring NOTE: also moved the uptime command in the embed_commands module. --- src/commands/embed_commands.rs | 745 ------------------ src/commands/embed_commands/avatar.rs | 21 + src/commands/embed_commands/bonk.rs | 57 ++ src/commands/embed_commands/boom.rs | 20 + src/commands/embed_commands/bury.rs | 50 ++ src/commands/embed_commands/chair.rs | 21 + src/commands/embed_commands/drive.rs | 16 + src/commands/embed_commands/hug.rs | 59 ++ src/commands/embed_commands/kick.rs | 51 ++ src/commands/embed_commands/kill.rs | 48 ++ src/commands/embed_commands/kiss.rs | 63 ++ src/commands/embed_commands/mod.rs | 66 ++ src/commands/embed_commands/nom.rs | 59 ++ src/commands/embed_commands/pat.rs | 59 ++ src/commands/embed_commands/peek.rs | 23 + src/commands/embed_commands/punch.rs | 48 ++ src/commands/embed_commands/selfbury.rs | 23 + src/commands/embed_commands/slap.rs | 64 ++ src/commands/embed_commands/tieup.rs | 64 ++ .../uptime.rs} | 5 +- src/commands/general_commands/age.rs | 17 + .../help.rs} | 20 +- src/commands/general_commands/mod.rs | 10 + src/commands/level_cmds.rs | 168 ---- src/commands/level_cmds/level.rs | 79 ++ src/commands/level_cmds/mod.rs | 19 + src/commands/level_cmds/toplevels.rs | 79 ++ src/commands/mod.rs | 1 - src/main.rs | 2 +- 29 files changed, 1019 insertions(+), 938 deletions(-) delete mode 100644 src/commands/embed_commands.rs create mode 100644 src/commands/embed_commands/avatar.rs create mode 100644 src/commands/embed_commands/bonk.rs create mode 100644 src/commands/embed_commands/boom.rs create mode 100644 src/commands/embed_commands/bury.rs create mode 100644 src/commands/embed_commands/chair.rs create mode 100644 src/commands/embed_commands/drive.rs create mode 100644 src/commands/embed_commands/hug.rs create mode 100644 src/commands/embed_commands/kick.rs create mode 100644 src/commands/embed_commands/kill.rs create mode 100644 src/commands/embed_commands/kiss.rs create mode 100644 src/commands/embed_commands/mod.rs create mode 100644 src/commands/embed_commands/nom.rs create mode 100644 src/commands/embed_commands/pat.rs create mode 100644 src/commands/embed_commands/peek.rs create mode 100644 src/commands/embed_commands/punch.rs create mode 100644 src/commands/embed_commands/selfbury.rs create mode 100644 src/commands/embed_commands/slap.rs create mode 100644 src/commands/embed_commands/tieup.rs rename src/commands/{util_commands.rs => embed_commands/uptime.rs} (88%) create mode 100644 src/commands/general_commands/age.rs rename src/commands/{general_commands.rs => general_commands/help.rs} (71%) create mode 100644 src/commands/general_commands/mod.rs delete mode 100644 src/commands/level_cmds.rs create mode 100644 src/commands/level_cmds/level.rs create mode 100644 src/commands/level_cmds/mod.rs create mode 100644 src/commands/level_cmds/toplevels.rs diff --git a/src/commands/embed_commands.rs b/src/commands/embed_commands.rs deleted file mode 100644 index 936ec6b..0000000 --- a/src/commands/embed_commands.rs +++ /dev/null @@ -1,745 +0,0 @@ -use crate::commands::{cmd_utils, cmd_utils::get_replied_user}; -use crate::data::command_data::{Context, Error}; -use crate::enums::command_enums::EmbedType; -use ::serenity::all::Mentionable; -use poise::serenity_prelude as serenity; -use std::sync::Arc; - -// This is where the poise framework shines since with it you can make -// a slash and a prefix command work in one function. -// -// Docs for reference: -// https://docs.rs/poise/latest/poise/reply/fn.send_reply.html - -// #region User interaction commands - -/// Tie someone up (HUH?) -#[poise::command(prefix_command, slash_command, rename = "tieup")] -pub async fn tieup( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::TieUp).await?; - let bot_user = Arc::clone(&ctx.data().bot_user); - if target_replied_user == ctx.author() { - ctx.send( - poise::CreateReply::default() - .content("Y'know what? Sure, I'll tie you up!") - .embed( - serenity::CreateEmbed::new() - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ), - ), - ) - .await?; - ctx.reply(format!( - "Did you like it {}? You filthy degenerate~", // true... - target_replied_user.mention() - )) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *ties up* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Pat someone -#[poise::command(prefix_command, slash_command, rename = "pat")] -pub async fn pat( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Pat).await?; - let bot_user = Arc::clone(&ctx.data().bot_user); - if target_replied_user == ctx.author() { - ctx.send( - poise::CreateReply::default() - .content("Aww~ I'll pat you!") - .embed( - serenity::CreateEmbed::new() - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ), - ), - ) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *pats* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Hug someone -#[poise::command(prefix_command, slash_command, rename = "hug")] -pub async fn hug( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Hug).await?; - let bot_user = Arc::clone(&ctx.data().bot_user); - if target_replied_user == ctx.author() { - ctx.send( - poise::CreateReply::default() - .content("Aww~ I'll hug you!") - .embed( - serenity::CreateEmbed::new() - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ), - ), - ) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *hugs* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Kiss someone -#[poise::command(prefix_command, slash_command, rename = "kiss")] -pub async fn kiss( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let bot_user = Arc::clone(&ctx.data().bot_user); - if target_replied_user == ctx.author() { - ctx.send( - poise::CreateReply::default() - .content("Aww~ I won't kiss you! Ahahahah!") - .embed( - serenity::CreateEmbed::new() - .color((255, 0, 0)) - .image( - cmd_utils::get_embed_from_type(&EmbedType::Slap) - .await? - .to_string(), - ) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ), - ), - ) - .await?; - return Ok(()); - } - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Kiss).await?; - - let response: String = format!( - "**{}** *kisses* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Slap someone -#[poise::command(prefix_command, slash_command, rename = "slap")] -pub async fn slap( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Slap).await?; - let bot_user = Arc::clone(&ctx.data().bot_user); - if target_replied_user == ctx.author() { - ctx.send( - poise::CreateReply::default() - .content("Why do you want to get slapped??") - .embed( - serenity::CreateEmbed::new() - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ), - ), - ) - .await?; - ctx.reply(format!( - "Did you like it? {}", - target_replied_user.mention() - )) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *slaps* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Punch someone -#[poise::command(prefix_command, slash_command, rename = "punch")] -pub async fn punch( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Punch).await?; - if target_replied_user == ctx.author() { - ctx.send(poise::CreateReply::default().content("I won't punch you! *pouts*")) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *punches* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let bot_user = Arc::clone(&ctx.data().bot_user); - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Bonk someone who's horknee -#[poise::command(prefix_command, slash_command, rename = "bonk")] -pub async fn bonk( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Bonk).await?; - let bot_user = Arc::clone(&ctx.data().bot_user); - if target_replied_user == ctx.author() { - ctx.send( - poise::CreateReply::default().content("バカ!").embed( - serenity::CreateEmbed::new() - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ), - ), - ) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *bonks* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Nom someone -#[poise::command(prefix_command, slash_command, rename = "nom")] -pub async fn nom( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Nom).await?; - let bot_user = Arc::clone(&ctx.data().bot_user); - if target_replied_user == ctx.author() { - ctx.send( - poise::CreateReply::default() - .content(format!("{} noms themselves...?", target_replied_user.name)) - .embed( - serenity::CreateEmbed::new() - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ), - ), - ) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *noms* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Kill someone (Sadge) -#[poise::command(prefix_command, slash_command, rename = "kill")] -pub async fn kill( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Kill).await?; - if target_replied_user == ctx.author() { - ctx.send(poise::CreateReply::default().content("No.")) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *kills* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let bot_user = Arc::clone(&ctx.data().bot_user); - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Kick someone -#[poise::command(prefix_command, slash_command, rename = "kick")] -pub async fn kick( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Kick).await?; - if target_replied_user == ctx.author() { - ctx.send(poise::CreateReply::default().content(format!( - "{}, why would you kick yourself...? Weirdo...", - target_replied_user.mention() - ))) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *kicks* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - - let bot_user = Arc::clone(&ctx.data().bot_user); - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Bury someone -#[poise::command(prefix_command, slash_command, rename = "bury")] -pub async fn bury( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Bury).await?; - if target_replied_user == ctx.author() { - ctx.send(poise::CreateReply::default().content(format!( - "{} Just use the `!selfbury` or `/selfbury` command bruh...", - target_replied_user.mention() - ))) - .await?; - return Ok(()); - } - - let response: String = format!( - "**{}** *buries* **{}**", - ctx.author().name, - target_replied_user.name - ); - - let ping_on_shash_command: Option = match ctx { - poise::Context::Prefix(_) => None, - poise::Context::Application(_) => Some(target_replied_user.mention()), - }; - let bot_user = Arc::clone(&ctx.data().bot_user); - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default() - .content(match ping_on_shash_command { - Some(ping) => format!("{}", ping), - None => "".to_owned(), - }) - .embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Bury yourself (perhaps to help Hu Tao's busines idk...) -#[poise::command(prefix_command, slash_command, rename = "selfbury")] -pub async fn selfbury(ctx: Context<'_>) -> Result<(), Error> { - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::SelfBury).await?; - let response: String = format!("**{}** *buries themselves*", ctx.author().name,); - let bot_user = Arc::clone(&ctx.data().bot_user); - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default().embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Send a peek GIF in the chat (you lurker) -#[poise::command(prefix_command, slash_command, rename = "peek")] -pub async fn peek(ctx: Context<'_>) -> Result<(), Error> { - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Peek).await?; - let response: String = format!("{} is lurking . . .", ctx.author().name,); - let bot_user = Arc::clone(&ctx.data().bot_user); - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(embed_item.to_string()) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - - let full_respone = poise::CreateReply::default().embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -// #endregion - -/// Get the avatar for someone. -#[poise::command(slash_command, prefix_command, rename = "avatar")] -pub async fn avatar( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let response: String = format!("**{}**'s avatar:", target_replied_user.name); - let user_avatar_as_embed: String = target_replied_user.face().replace(".webp", ".png"); - - let embed = serenity::CreateEmbed::new() - .title(response) - .color((255, 0, 0)) - .image(user_avatar_as_embed); - let full_respone = poise::CreateReply::default().embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Get a Ryan Gosling drive GIF. -#[poise::command(slash_command, prefix_command, rename = "drive")] -pub async fn drive(ctx: Context<'_>) -> Result<(), Error> { - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::RyanGoslingDrive).await?; - - let embed = serenity::CreateEmbed::new() - // .title() - .color((255, 0, 0)) - .image(embed_item); - let full_respone = poise::CreateReply::default().embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Get a motivation chair GIF -#[poise::command(slash_command, prefix_command, rename = "chair")] -pub async fn chair(ctx: Context<'_>) -> Result<(), Error> { - let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Chair).await?; - let bot_user = Arc::clone(&ctx.data().bot_user); - - let embed = serenity::CreateEmbed::new() - .title("You need some motivation!") - .color((255, 0, 0)) - .image(embed_item) - .footer( - serenity::CreateEmbedFooter::new(bot_user.tag()) - .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), - ); - let full_respone = poise::CreateReply::default().embed(embed); - ctx.send(full_respone).await?; - - Ok(()) -} - -/// Just try it. -#[poise::command(slash_command, prefix_command, rename = "boom")] -pub async fn boom(ctx: Context<'_>) -> Result<(), Error> { - let bot_user = Arc::clone(&ctx.data().bot_user); - let bot_avatar = bot_user.face().replace(".webp", ".png"); - - ctx.send( - poise::CreateReply::default().embed( - serenity::CreateEmbed::default() - .image("https://raw.githubusercontent.com/1Git2Clone/serenity-discord-bot/main/src/assets/hu_boom.jpg") - .color((255, 0, 0)) - .footer(serenity::CreateEmbedFooter::new(bot_user.tag()).icon_url(bot_avatar)), - ), - ) - .await?; - - Ok(()) -} diff --git a/src/commands/embed_commands/avatar.rs b/src/commands/embed_commands/avatar.rs new file mode 100644 index 0000000..907ea7e --- /dev/null +++ b/src/commands/embed_commands/avatar.rs @@ -0,0 +1,21 @@ +use super::*; + +/// Get the avatar for someone. +#[poise::command(slash_command, prefix_command, rename = "avatar")] +pub async fn avatar( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let response: String = format!("**{}**'s avatar:", target_replied_user.name); + let user_avatar_as_embed: String = target_replied_user.face().replace(".webp", ".png"); + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(user_avatar_as_embed); + let full_respone = poise::CreateReply::default().embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/bonk.rs b/src/commands/embed_commands/bonk.rs new file mode 100644 index 0000000..819a5db --- /dev/null +++ b/src/commands/embed_commands/bonk.rs @@ -0,0 +1,57 @@ +use super::*; + +/// Bonk someone who's horknee +#[poise::command(prefix_command, slash_command, rename = "bonk")] +pub async fn bonk( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Bonk).await?; + let bot_user = Arc::clone(&ctx.data().bot_user); + if target_replied_user == ctx.author() { + ctx.send( + poise::CreateReply::default().content("バカ!").embed( + serenity::CreateEmbed::new() + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ), + ), + ) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *bonks* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/boom.rs b/src/commands/embed_commands/boom.rs new file mode 100644 index 0000000..d331064 --- /dev/null +++ b/src/commands/embed_commands/boom.rs @@ -0,0 +1,20 @@ +use super::*; + +/// Just try it. +#[poise::command(slash_command, prefix_command, rename = "boom")] +pub async fn boom(ctx: Context<'_>) -> Result<(), Error> { + let bot_user = Arc::clone(&ctx.data().bot_user); + let bot_avatar = bot_user.face().replace(".webp", ".png"); + + ctx.send( + poise::CreateReply::default().embed( + serenity::CreateEmbed::default() + .image("https://raw.githubusercontent.com/1Git2Clone/serenity-discord-bot/main/src/assets/hu_boom.jpg") + .color((255, 0, 0)) + .footer(serenity::CreateEmbedFooter::new(bot_user.tag()).icon_url(bot_avatar)), + ), + ) + .await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/bury.rs b/src/commands/embed_commands/bury.rs new file mode 100644 index 0000000..e0b9f26 --- /dev/null +++ b/src/commands/embed_commands/bury.rs @@ -0,0 +1,50 @@ +use super::*; + +/// Bury someone +#[poise::command(prefix_command, slash_command, rename = "bury")] +pub async fn bury( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Bury).await?; + if target_replied_user == ctx.author() { + ctx.send(poise::CreateReply::default().content(format!( + "{} Just use the `!selfbury` or `/selfbury` command bruh...", + target_replied_user.mention() + ))) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *buries* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + let bot_user = Arc::clone(&ctx.data().bot_user); + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/chair.rs b/src/commands/embed_commands/chair.rs new file mode 100644 index 0000000..5f0f681 --- /dev/null +++ b/src/commands/embed_commands/chair.rs @@ -0,0 +1,21 @@ +use super::*; + +/// Get a motivation chair GIF +#[poise::command(slash_command, prefix_command, rename = "chair")] +pub async fn chair(ctx: Context<'_>) -> Result<(), Error> { + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Chair).await?; + let bot_user = Arc::clone(&ctx.data().bot_user); + + let embed = serenity::CreateEmbed::new() + .title("You need some motivation!") + .color((255, 0, 0)) + .image(embed_item) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + let full_respone = poise::CreateReply::default().embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/drive.rs b/src/commands/embed_commands/drive.rs new file mode 100644 index 0000000..903fb20 --- /dev/null +++ b/src/commands/embed_commands/drive.rs @@ -0,0 +1,16 @@ +use super::*; + +/// Get a Ryan Gosling drive GIF. +#[poise::command(slash_command, prefix_command, rename = "drive")] +pub async fn drive(ctx: Context<'_>) -> Result<(), Error> { + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::RyanGoslingDrive).await?; + + let embed = serenity::CreateEmbed::new() + // .title() + .color((255, 0, 0)) + .image(embed_item); + let full_respone = poise::CreateReply::default().embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/hug.rs b/src/commands/embed_commands/hug.rs new file mode 100644 index 0000000..c846806 --- /dev/null +++ b/src/commands/embed_commands/hug.rs @@ -0,0 +1,59 @@ +use super::*; + +/// Hug someone +#[poise::command(prefix_command, slash_command, rename = "hug")] +pub async fn hug( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Hug).await?; + let bot_user = Arc::clone(&ctx.data().bot_user); + if target_replied_user == ctx.author() { + ctx.send( + poise::CreateReply::default() + .content("Aww~ I'll hug you!") + .embed( + serenity::CreateEmbed::new() + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ), + ), + ) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *hugs* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/kick.rs b/src/commands/embed_commands/kick.rs new file mode 100644 index 0000000..1305978 --- /dev/null +++ b/src/commands/embed_commands/kick.rs @@ -0,0 +1,51 @@ +use super::*; + +/// Kick someone +#[poise::command(prefix_command, slash_command, rename = "kick")] +pub async fn kick( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Kick).await?; + if target_replied_user == ctx.author() { + ctx.send(poise::CreateReply::default().content(format!( + "{}, why would you kick yourself...? Weirdo...", + target_replied_user.mention() + ))) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *kicks* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let bot_user = Arc::clone(&ctx.data().bot_user); + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/kill.rs b/src/commands/embed_commands/kill.rs new file mode 100644 index 0000000..0861917 --- /dev/null +++ b/src/commands/embed_commands/kill.rs @@ -0,0 +1,48 @@ +use super::*; + +/// Kill someone (Sadge) +#[poise::command(prefix_command, slash_command, rename = "kill")] +pub async fn kill( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Kill).await?; + if target_replied_user == ctx.author() { + ctx.send(poise::CreateReply::default().content("No.")) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *kills* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let bot_user = Arc::clone(&ctx.data().bot_user); + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/kiss.rs b/src/commands/embed_commands/kiss.rs new file mode 100644 index 0000000..8625a9a --- /dev/null +++ b/src/commands/embed_commands/kiss.rs @@ -0,0 +1,63 @@ +use super::*; + +/// Kiss someone +#[poise::command(prefix_command, slash_command, rename = "kiss")] +pub async fn kiss( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let bot_user = Arc::clone(&ctx.data().bot_user); + if target_replied_user == ctx.author() { + ctx.send( + poise::CreateReply::default() + .content("Aww~ I won't kiss you! Ahahahah!") + .embed( + serenity::CreateEmbed::new() + .color((255, 0, 0)) + .image( + cmd_utils::get_embed_from_type(&EmbedType::Slap) + .await? + .to_string(), + ) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ), + ), + ) + .await?; + return Ok(()); + } + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Kiss).await?; + + let response: String = format!( + "**{}** *kisses* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/mod.rs b/src/commands/embed_commands/mod.rs new file mode 100644 index 0000000..7dd91a7 --- /dev/null +++ b/src/commands/embed_commands/mod.rs @@ -0,0 +1,66 @@ +/// dependencies for the commands. +use crate::commands::{cmd_utils, cmd_utils::get_replied_user}; +use crate::data::bot_data::START_TIME; +use crate::data::command_data::{Context, Error}; +use crate::enums::command_enums::EmbedType; +use ::serenity::all::Mentionable; +use poise::serenity_prelude as serenity; +use std::sync::Arc; + +// #region User interaction commands + +pub mod tieup; +pub use tieup::tieup; + +pub mod pat; +pub use pat::pat; + +pub mod hug; +pub use hug::hug; + +pub mod kiss; +pub use kiss::kiss; + +pub mod slap; +pub use slap::slap; + +pub mod punch; +pub use punch::punch; + +pub mod bonk; +pub use bonk::bonk; + +pub mod nom; +pub use nom::nom; + +pub mod kill; +pub use kill::kill; + +pub mod kick; +pub use kick::kick; + +pub mod bury; +pub use bury::bury; + +pub mod selfbury; +pub use selfbury::selfbury; + +pub mod peek; +pub use peek::peek; + +// #endregion + +pub mod avatar; +pub use avatar::avatar; + +pub mod drive; +pub use drive::drive; + +pub mod chair; +pub use chair::chair; + +pub mod boom; +pub use boom::boom; + +pub mod uptime; +pub use uptime::uptime; diff --git a/src/commands/embed_commands/nom.rs b/src/commands/embed_commands/nom.rs new file mode 100644 index 0000000..d391501 --- /dev/null +++ b/src/commands/embed_commands/nom.rs @@ -0,0 +1,59 @@ +use super::*; + +/// Nom someone +#[poise::command(prefix_command, slash_command, rename = "nom")] +pub async fn nom( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Nom).await?; + let bot_user = Arc::clone(&ctx.data().bot_user); + if target_replied_user == ctx.author() { + ctx.send( + poise::CreateReply::default() + .content(format!("{} noms themselves...?", target_replied_user.name)) + .embed( + serenity::CreateEmbed::new() + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ), + ), + ) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *noms* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/pat.rs b/src/commands/embed_commands/pat.rs new file mode 100644 index 0000000..8385db6 --- /dev/null +++ b/src/commands/embed_commands/pat.rs @@ -0,0 +1,59 @@ +use super::*; + +/// Pat someone +#[poise::command(prefix_command, slash_command, rename = "pat")] +pub async fn pat( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Pat).await?; + let bot_user = Arc::clone(&ctx.data().bot_user); + if target_replied_user == ctx.author() { + ctx.send( + poise::CreateReply::default() + .content("Aww~ I'll pat you!") + .embed( + serenity::CreateEmbed::new() + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ), + ), + ) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *pats* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/peek.rs b/src/commands/embed_commands/peek.rs new file mode 100644 index 0000000..da482dd --- /dev/null +++ b/src/commands/embed_commands/peek.rs @@ -0,0 +1,23 @@ +use super::*; + +/// Send a peek GIF in the chat (you lurker) +#[poise::command(prefix_command, slash_command, rename = "peek")] +pub async fn peek(ctx: Context<'_>) -> Result<(), Error> { + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Peek).await?; + let response: String = format!("{} is lurking . . .", ctx.author().name,); + let bot_user = Arc::clone(&ctx.data().bot_user); + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default().embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/punch.rs b/src/commands/embed_commands/punch.rs new file mode 100644 index 0000000..72fb860 --- /dev/null +++ b/src/commands/embed_commands/punch.rs @@ -0,0 +1,48 @@ +use super::*; + +/// Punch someone +#[poise::command(prefix_command, slash_command, rename = "punch")] +pub async fn punch( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Punch).await?; + if target_replied_user == ctx.author() { + ctx.send(poise::CreateReply::default().content("I won't punch you! *pouts*")) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *punches* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let bot_user = Arc::clone(&ctx.data().bot_user); + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/selfbury.rs b/src/commands/embed_commands/selfbury.rs new file mode 100644 index 0000000..b667f20 --- /dev/null +++ b/src/commands/embed_commands/selfbury.rs @@ -0,0 +1,23 @@ +use super::*; + +/// Bury yourself (perhaps to help Hu Tao's busines idk...) +#[poise::command(prefix_command, slash_command, rename = "selfbury")] +pub async fn selfbury(ctx: Context<'_>) -> Result<(), Error> { + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::SelfBury).await?; + let response: String = format!("**{}** *buries themselves*", ctx.author().name,); + let bot_user = Arc::clone(&ctx.data().bot_user); + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default().embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/slap.rs b/src/commands/embed_commands/slap.rs new file mode 100644 index 0000000..7640868 --- /dev/null +++ b/src/commands/embed_commands/slap.rs @@ -0,0 +1,64 @@ +use super::*; + +/// Slap someone +#[poise::command(prefix_command, slash_command, rename = "slap")] +pub async fn slap( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Slap).await?; + let bot_user = Arc::clone(&ctx.data().bot_user); + if target_replied_user == ctx.author() { + ctx.send( + poise::CreateReply::default() + .content("Why do you want to get slapped??") + .embed( + serenity::CreateEmbed::new() + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ), + ), + ) + .await?; + ctx.reply(format!( + "Did you like it? {}", + target_replied_user.mention() + )) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *slaps* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/embed_commands/tieup.rs b/src/commands/embed_commands/tieup.rs new file mode 100644 index 0000000..ed3e0e5 --- /dev/null +++ b/src/commands/embed_commands/tieup.rs @@ -0,0 +1,64 @@ +use super::*; + +/// Tie someone up (HUH?) +#[poise::command(prefix_command, slash_command, rename = "tieup")] +pub async fn tieup( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::TieUp).await?; + let bot_user = Arc::clone(&ctx.data().bot_user); + if target_replied_user == ctx.author() { + ctx.send( + poise::CreateReply::default() + .content("Y'know what? Sure, I'll tie you up!") + .embed( + serenity::CreateEmbed::new() + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ), + ), + ) + .await?; + ctx.reply(format!( + "Did you like it {}? You filthy degenerate~", // true... + target_replied_user.mention() + )) + .await?; + return Ok(()); + } + + let response: String = format!( + "**{}** *ties up* **{}**", + ctx.author().name, + target_replied_user.name + ); + + let ping_on_shash_command: Option = match ctx { + poise::Context::Prefix(_) => None, + poise::Context::Application(_) => Some(target_replied_user.mention()), + }; + + let embed = serenity::CreateEmbed::new() + .title(response) + .color((255, 0, 0)) + .image(embed_item.to_string()) + .footer( + serenity::CreateEmbedFooter::new(bot_user.tag()) + .icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()), + ); + + let full_respone = poise::CreateReply::default() + .content(match ping_on_shash_command { + Some(ping) => format!("{}", ping), + None => "".to_owned(), + }) + .embed(embed); + ctx.send(full_respone).await?; + + Ok(()) +} diff --git a/src/commands/util_commands.rs b/src/commands/embed_commands/uptime.rs similarity index 88% rename from src/commands/util_commands.rs rename to src/commands/embed_commands/uptime.rs index 47b60af..738b397 100644 --- a/src/commands/util_commands.rs +++ b/src/commands/embed_commands/uptime.rs @@ -1,7 +1,4 @@ -use crate::data::bot_data::START_TIME; -use crate::data::command_data::{Context, Error}; -use poise::serenity_prelude as serenity; -use std::sync::Arc; +use super::*; /// Displays the bot's current uptime #[poise::command(slash_command, prefix_command, rename = "uptime")] diff --git a/src/commands/general_commands/age.rs b/src/commands/general_commands/age.rs new file mode 100644 index 0000000..8d00da1 --- /dev/null +++ b/src/commands/general_commands/age.rs @@ -0,0 +1,17 @@ +use super::*; + +/// Displays your or another user's account creation date +#[poise::command(slash_command, prefix_command, rename = "age")] +pub async fn age( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let response = format!( + "**{}**'s account was created at {}", + target_replied_user.name, + target_replied_user.created_at() + ); + ctx.say(response).await?; + Ok(()) +} diff --git a/src/commands/general_commands.rs b/src/commands/general_commands/help.rs similarity index 71% rename from src/commands/general_commands.rs rename to src/commands/general_commands/help.rs index cd245d8..1702abd 100644 --- a/src/commands/general_commands.rs +++ b/src/commands/general_commands/help.rs @@ -1,6 +1,4 @@ -use crate::commands::cmd_utils::get_replied_user; -use crate::data::command_data::{Context, Error}; -use poise::serenity_prelude as serenity; +use super::*; /// Show this help menu #[poise::command(prefix_command, track_edits, slash_command)] @@ -38,19 +36,3 @@ pub async fn help( Ok(()) } - -/// Displays your or another user's account creation date -#[poise::command(slash_command, prefix_command, rename = "age")] -pub async fn age( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let response = format!( - "**{}**'s account was created at {}", - target_replied_user.name, - target_replied_user.created_at() - ); - ctx.say(response).await?; - Ok(()) -} diff --git a/src/commands/general_commands/mod.rs b/src/commands/general_commands/mod.rs new file mode 100644 index 0000000..91d1c96 --- /dev/null +++ b/src/commands/general_commands/mod.rs @@ -0,0 +1,10 @@ +/// dependencies for the commands. +use crate::commands::cmd_utils::get_replied_user; +use crate::data::command_data::{Context, Error}; +use poise::serenity_prelude as serenity; + +pub mod help; +pub use help::help; + +pub mod age; +pub use age::age; diff --git a/src/commands/level_cmds.rs b/src/commands/level_cmds.rs deleted file mode 100644 index 770f24b..0000000 --- a/src/commands/level_cmds.rs +++ /dev/null @@ -1,168 +0,0 @@ -use crate::commands::cmd_utils::get_replied_user; -use crate::data::bot_data::{DATABASE_COLUMNS, DATABASE_FILENAME}; -use crate::data::command_data::{Context, Error}; -use crate::data::database_interactions::{ - connect_to_db, fetch_top_nine_levels_in_guild, fetch_user_level_and_rank, -}; -use crate::enums::schemas::DatabaseSchema::*; -use ::serenity::futures::future::try_join_all; -use poise::serenity_prelude as serenity; -use rayon::prelude::*; -use sqlx::Row; -use std::sync::Arc; - -/// Displays the user's level -#[poise::command(slash_command, prefix_command, rename = "level")] -pub async fn level( - ctx: Context<'_>, - #[description = "Selected user"] user: Option, -) -> Result<(), Error> { - let message_guild_id = match ctx.guild_id() { - Some(msg) => msg, - None => { - ctx.reply("Please use the fucking guild chats you sick fuck!") - .await?; - return Ok(()); - } - }; - - let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); - let db = connect_to_db(DATABASE_FILENAME.to_string()).await; - let level_xp_and_rank_row_option = match db.await { - Ok(pool) => { - println!("Connected to the database: {pool:?}"); - fetch_user_level_and_rank(&pool, target_replied_user, message_guild_id).await? - } - Err(_) => { - ctx.reply(format!( - "Please wait for {} to chat more then try again later...", - target_replied_user.name - )) - .await?; - return Ok(()); - } - }; - let level_xp_and_rank_row = if let Some(lvl_xp_and_rank_row) = level_xp_and_rank_row_option { - lvl_xp_and_rank_row - } else { - ctx.reply(format!( - "Please wait for {} to chat more then try again later...", - target_replied_user.name - )) - .await?; - return Ok(()); - }; - let level = level_xp_and_rank_row - .1 - .get::(DATABASE_COLUMNS[&Level]); - let xp = level_xp_and_rank_row - .1 - .get::(DATABASE_COLUMNS[&ExperiencePoints]); - - let avatar = target_replied_user.face().replace(".webp", ".png"); - let username = &target_replied_user.name; - let response = format!( - "User stats for: **{}**\n\nRank: {}", - &username, level_xp_and_rank_row.0 - ); - let bot_user = Arc::clone(&ctx.data().bot_user); - let bot_avatar = Arc::clone(&ctx.data().bot_avatar).to_string(); - let percent_left_to_level_up: f32 = (xp as f32) / (level as f32); - ctx.send( - poise::CreateReply::default().embed( - serenity::CreateEmbed::default() - .title(response) - .url("") - .color((255, 0, 0)) - .thumbnail(&avatar) - .field("Level", format!("⊱ {}", level), false) - .field("Experience Points", format!("⊱ {}", xp), false) - .field( - "Progress until next level", - format!("⊱ {:.2}%", percent_left_to_level_up), - false, - ) - .footer(serenity::CreateEmbedFooter::new(bot_user.tag()).icon_url(bot_avatar)), - ), - ) - .await?; - Ok(()) -} - -/// Displays the levels for the top 9 users. -#[poise::command(slash_command, prefix_command, rename = "toplevels")] -pub async fn toplevels(ctx: Context<'_>) -> Result<(), Error> { - let message_guild_id = match ctx.guild_id() { - Some(msg) => msg, - None => { - ctx.reply("Please use the fucking guild chats you sick fuck!") - .await?; - return Ok(()); - } - }; - - let db = connect_to_db(DATABASE_FILENAME.to_string()).await; - - let level_and_xp_rows = match db.await { - Ok(pool) => fetch_top_nine_levels_in_guild(&pool, message_guild_id).await?, - Err(_) => { - ctx.reply("Please wait for the guild members to chat more.") - .await?; - return Ok(()); - } - }; - ctx.defer().await?; - let user_ids: Vec = level_and_xp_rows - .par_iter() - .map(|row| row.get::(DATABASE_COLUMNS[&UserId]) as u64) - .collect(); - let users = try_join_all( - user_ids - .iter() - .map(|user_id| ctx.http().get_user((*user_id).into())), - ) - .await?; - - let mut fields: Vec<(String, String, bool)> = Vec::new(); - - for (counter, (row, user)) in level_and_xp_rows.iter().zip(users.iter()).enumerate() { - let (level, xp) = ( - row.get::(DATABASE_COLUMNS[&Level]), - row.get::(DATABASE_COLUMNS[&ExperiencePoints]), - ); - - fields.push(( - format!("#{} >> {}", counter + 1, user.name), - format!( - "Lvl: {}\nXP: {}\nLevel progress: {:.2}%", - level, - xp, - ((xp as f32) / (level as f32)) - ), - false, - )); - } - - let response = format!("Guild: {}\n\nTop 9 Users", ctx.guild().unwrap().name); - let bot_user = Arc::clone(&ctx.data().bot_user); - let bot_avatar = Arc::clone(&ctx.data().bot_avatar).to_string(); - - let thumbnail = ctx - .guild() - .and_then(|guild| guild.icon_url()) - .unwrap_or_else(|| bot_avatar.to_owned()); - - ctx.send( - poise::CreateReply::default().embed( - serenity::CreateEmbed::default() - .title(response) - .fields(fields) - .thumbnail(thumbnail) - .color((255, 0, 0)) - .footer(serenity::CreateEmbedFooter::new(bot_user.tag()).icon_url(bot_avatar)), - ), - ) - .await?; - - Ok(()) -} diff --git a/src/commands/level_cmds/level.rs b/src/commands/level_cmds/level.rs new file mode 100644 index 0000000..420cf42 --- /dev/null +++ b/src/commands/level_cmds/level.rs @@ -0,0 +1,79 @@ +use super::*; + +/// Displays the user's level +#[poise::command(slash_command, prefix_command, rename = "level")] +pub async fn level( + ctx: Context<'_>, + #[description = "Selected user"] user: Option, +) -> Result<(), Error> { + let message_guild_id = match ctx.guild_id() { + Some(msg) => msg, + None => { + ctx.reply("Please use the fucking guild chats you sick fuck!") + .await?; + return Ok(()); + } + }; + + let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await); + let db = connect_to_db(DATABASE_FILENAME.to_string()).await; + let level_xp_and_rank_row_option = match db.await { + Ok(pool) => { + println!("Connected to the database: {pool:?}"); + fetch_user_level_and_rank(&pool, target_replied_user, message_guild_id).await? + } + Err(_) => { + ctx.reply(format!( + "Please wait for {} to chat more then try again later...", + target_replied_user.name + )) + .await?; + return Ok(()); + } + }; + let level_xp_and_rank_row = if let Some(lvl_xp_and_rank_row) = level_xp_and_rank_row_option { + lvl_xp_and_rank_row + } else { + ctx.reply(format!( + "Please wait for {} to chat more then try again later...", + target_replied_user.name + )) + .await?; + return Ok(()); + }; + let level = level_xp_and_rank_row + .1 + .get::(DATABASE_COLUMNS[&Level]); + let xp = level_xp_and_rank_row + .1 + .get::(DATABASE_COLUMNS[&ExperiencePoints]); + + let avatar = target_replied_user.face().replace(".webp", ".png"); + let username = &target_replied_user.name; + let response = format!( + "User stats for: **{}**\n\nRank: {}", + &username, level_xp_and_rank_row.0 + ); + let bot_user = Arc::clone(&ctx.data().bot_user); + let bot_avatar = Arc::clone(&ctx.data().bot_avatar).to_string(); + let percent_left_to_level_up: f32 = (xp as f32) / (level as f32); + ctx.send( + poise::CreateReply::default().embed( + serenity::CreateEmbed::default() + .title(response) + .url("") + .color((255, 0, 0)) + .thumbnail(&avatar) + .field("Level", format!("⊱ {}", level), false) + .field("Experience Points", format!("⊱ {}", xp), false) + .field( + "Progress until next level", + format!("⊱ {:.2}%", percent_left_to_level_up), + false, + ) + .footer(serenity::CreateEmbedFooter::new(bot_user.tag()).icon_url(bot_avatar)), + ), + ) + .await?; + Ok(()) +} diff --git a/src/commands/level_cmds/mod.rs b/src/commands/level_cmds/mod.rs new file mode 100644 index 0000000..dac923c --- /dev/null +++ b/src/commands/level_cmds/mod.rs @@ -0,0 +1,19 @@ +/// dependencies for the commands. +use crate::commands::cmd_utils::get_replied_user; +use crate::data::bot_data::{DATABASE_COLUMNS, DATABASE_FILENAME}; +use crate::data::command_data::{Context, Error}; +use crate::data::database_interactions::{ + connect_to_db, fetch_top_nine_levels_in_guild, fetch_user_level_and_rank, +}; +use crate::enums::schemas::DatabaseSchema::*; +use ::serenity::futures::future::try_join_all; +use poise::serenity_prelude as serenity; +use rayon::prelude::*; +use sqlx::Row; +use std::sync::Arc; + +pub mod level; +pub use level::level; + +pub mod toplevels; +pub use toplevels::toplevels; diff --git a/src/commands/level_cmds/toplevels.rs b/src/commands/level_cmds/toplevels.rs new file mode 100644 index 0000000..4557ef9 --- /dev/null +++ b/src/commands/level_cmds/toplevels.rs @@ -0,0 +1,79 @@ +use super::*; + +/// Displays the levels for the top 9 users. +#[poise::command(slash_command, prefix_command, rename = "toplevels")] +pub async fn toplevels(ctx: Context<'_>) -> Result<(), Error> { + let message_guild_id = match ctx.guild_id() { + Some(msg) => msg, + None => { + ctx.reply("Please use the fucking guild chats you sick fuck!") + .await?; + return Ok(()); + } + }; + + let db = connect_to_db(DATABASE_FILENAME.to_string()).await; + + let level_and_xp_rows = match db.await { + Ok(pool) => fetch_top_nine_levels_in_guild(&pool, message_guild_id).await?, + Err(_) => { + ctx.reply("Please wait for the guild members to chat more.") + .await?; + return Ok(()); + } + }; + ctx.defer().await?; + let user_ids: Vec = level_and_xp_rows + .par_iter() + .map(|row| row.get::(DATABASE_COLUMNS[&UserId]) as u64) + .collect(); + let users = try_join_all( + user_ids + .iter() + .map(|user_id| ctx.http().get_user((*user_id).into())), + ) + .await?; + + let mut fields: Vec<(String, String, bool)> = Vec::new(); + + for (counter, (row, user)) in level_and_xp_rows.iter().zip(users.iter()).enumerate() { + let (level, xp) = ( + row.get::(DATABASE_COLUMNS[&Level]), + row.get::(DATABASE_COLUMNS[&ExperiencePoints]), + ); + + fields.push(( + format!("#{} >> {}", counter + 1, user.name), + format!( + "Lvl: {}\nXP: {}\nLevel progress: {:.2}%", + level, + xp, + ((xp as f32) / (level as f32)) + ), + false, + )); + } + + let response = format!("Guild: {}\n\nTop 9 Users", ctx.guild().unwrap().name); + let bot_user = Arc::clone(&ctx.data().bot_user); + let bot_avatar = Arc::clone(&ctx.data().bot_avatar).to_string(); + + let thumbnail = ctx + .guild() + .and_then(|guild| guild.icon_url()) + .unwrap_or_else(|| bot_avatar.to_owned()); + + ctx.send( + poise::CreateReply::default().embed( + serenity::CreateEmbed::default() + .title(response) + .fields(fields) + .thumbnail(thumbnail) + .color((255, 0, 0)) + .footer(serenity::CreateEmbedFooter::new(bot_user.tag()).icon_url(bot_avatar)), + ), + ) + .await?; + + Ok(()) +} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 19eb3a4..114b617 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -3,4 +3,3 @@ pub mod embed_commands; pub mod general_commands; pub mod level_cmds; pub mod level_logic; -pub mod util_commands; diff --git a/src/main.rs b/src/main.rs index 41d69fd..5592ada 100644 --- a/src/main.rs +++ b/src/main.rs @@ -186,7 +186,7 @@ async fn main() { commands::embed_commands::drive(), commands::embed_commands::chair(), commands::embed_commands::boom(), - commands::util_commands::uptime(), + commands::embed_commands::uptime(), ], manual_cooldowns: true, ..Default::default()