From fe9bcd7dc1833d5ba5ad75a84794217d8d840d56 Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 15 Nov 2023 23:43:45 -0500 Subject: refactor: merge bottom & convert --- src/commands/bottom.rs | 42 ------------------------------------------ src/commands/convert.rs | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 43 deletions(-) delete mode 100644 src/commands/bottom.rs (limited to 'src/commands') 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 { - 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)) + } + } +} -- cgit v1.2.3