diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands/bottom.rs | 42 | ||||
| -rw-r--r-- | src/commands/convert.rs | 37 | ||||
| -rw-r--r-- | src/main.rs | 26 |
3 files changed, 44 insertions, 61 deletions
diff --git a/src/commands/bottom.rs b/src/commands/bottom.rs deleted file mode 100644 index d38c4b8..0000000 --- a/src/commands/bottom.rs +++ /dev/null @@ -1,42 +0,0 @@ -use crate::{Context, Error}; -use bottomify::bottom::{decode_string, encode_string}; - -fn decode_sync(s: &str) -> Result<String, bottomify::bottom::TranslationError> { - decode_string(&s) -} - -#[poise::command(slash_command, subcommands("encode", "decode"))] -pub async fn bottom(_ctx: Context<'_>) -> Result<(), Error> { - Ok(()) -} - -/// teawie will translate to bottom 🥺 -#[poise::command(slash_command)] -pub async fn encode( - ctx: Context<'_>, - #[description = "what teawie will translate into bottom"] message: String, -) -> Result<(), Error> { - let encoded = encode_string(&message); - ctx.say(encoded).await?; - Ok(()) -} - -/// teawie will translate from bottom 🥸 -#[poise::command(slash_command)] -pub async fn decode( - ctx: Context<'_>, - #[description = "what teawie will translate from bottom"] message: String, -) -> Result<(), Error> { - let d = decode_sync(&message); - match d { - Ok(decoded) => { - ctx.say(decoded).await?; - Ok(()) - } - Err(why) => { - ctx.say("couldn't decode that for you, i'm sowwy!! :((".to_string()) - .await?; - Err(Box::new(why)) - } - } -} diff --git a/src/commands/convert.rs b/src/commands/convert.rs index c7e09c9..4e5d71c 100644 --- a/src/commands/convert.rs +++ b/src/commands/convert.rs @@ -1,6 +1,10 @@ use crate::{Context, Error}; +use bottomify::bottom::{decode_string, encode_string}; -#[poise::command(slash_command, subcommands("to_fahrenheit", "to_celsius"))] +#[poise::command( + slash_command, + subcommands("to_fahrenheit", "to_celsius", "to_bottom", "from_bottom") +)] pub async fn convert(_ctx: Context<'_>) -> Result<(), Error> { Ok(()) } @@ -26,3 +30,34 @@ pub async fn to_fahrenheit( ctx.say(temp.to_string()).await?; Ok(()) } + +/// teawie will translate to bottom 🥺 +#[poise::command(slash_command)] +pub async fn to_bottom( + ctx: Context<'_>, + #[description = "what teawie will translate into bottom"] message: String, +) -> Result<(), Error> { + let encoded = encode_string(&message); + ctx.say(encoded).await?; + Ok(()) +} + +/// teawie will translate from bottom 🥸 +#[poise::command(slash_command)] +pub async fn from_bottom( + ctx: Context<'_>, + #[description = "what teawie will translate from bottom"] message: String, +) -> Result<(), Error> { + let d = decode_string(&message); + match d { + Ok(decoded) => { + ctx.say(decoded).await?; + Ok(()) + } + Err(why) => { + ctx.say("couldn't decode that for you, i'm sowwy!! :((".to_string()) + .await?; + Err(Box::new(why)) + } + } +} diff --git a/src/main.rs b/src/main.rs index 749daae..c604df6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,8 @@ use std::time::Duration; use std::{env, error}; -use crate::commands::*; -use crate::consts::*; -use crate::pinboard::PinBoard; use log::*; +use pinboard::PinBoard; use poise::serenity_prelude as serentiy; use poise::serenity_prelude::*; @@ -58,21 +56,8 @@ async fn main() { env_logger::init(); dotenvy::dotenv().unwrap(); - let guild_commands = vec![copypasta::copypasta(), teawiespam::teawiespam()]; - let options = poise::FrameworkOptions { - commands: vec![ - ask::ask(), - bing::bing(), - bottom::bottom(), - convert::convert(), - random_lore::random_lore(), - random_shiggy::random_shiggy(), - random_teawie::random_teawie(), - copypasta::copypasta(), - teawiespam::teawiespam(), - version::version(), - ], + commands: commands::to_global_commands(), event_handler: |ctx, event, _, data| { Box::pin(async move { // yes this is dumb. no i don't care. @@ -105,7 +90,12 @@ async fn main() { poise::builtins::register_globally(ctx, &framework.options().commands).await?; info!("registered global commands!"); - poise::builtins::register_in_guild(ctx, &guild_commands, TEAWIE_GUILD).await?; + poise::builtins::register_in_guild( + ctx, + &commands::to_guild_commands(), + consts::TEAWIE_GUILD, + ) + .await?; info!("registered guild commands!"); Ok(Data::new()) |
