From 445822efad6682edbe0b1e27448b997fae9564c5 Mon Sep 17 00:00:00 2001 From: Leah Amelia Chen Date: Sun, 9 Jul 2023 18:38:31 -0600 Subject: Refactors + add pin board module (#32) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor according to the rules of the cone school of rustâ„¢ * Add pin board module * cargo fmt * More cleanups + appease clippy --- src/commands/bottom.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/commands/bottom.rs') diff --git a/src/commands/bottom.rs b/src/commands/bottom.rs index d25eab1..dbe74b9 100644 --- a/src/commands/bottom.rs +++ b/src/commands/bottom.rs @@ -5,9 +5,8 @@ use serenity::model::prelude::interaction::application_command::{ CommandDataOption, CommandDataOptionValue, }; -pub async fn run(options: &[CommandDataOption]) -> String { +pub fn run(options: &[CommandDataOption]) -> String { let err = "failed to get nested option in"; - let mut ret = "did you forget to enter a message?".to_string(); let data = options .get(0) @@ -16,6 +15,7 @@ pub async fn run(options: &[CommandDataOption]) -> String { // get subcommand to decide whether to encode/decode let subcommand = data.name.as_str(); + // TODO: this is horrendous // get message content let option = data .options @@ -27,19 +27,13 @@ pub async fn run(options: &[CommandDataOption]) -> String { if let CommandDataOptionValue::String(msg) = option { match subcommand { - "encode" => { - ret = bottom_encode(msg).await; - } - "decode" => { - ret = bottom_decode(msg).await; - } - _ => { - ret = "something went wrong :(".to_string(); - } - }; + "encode" => bottom_encode(msg), + "decode" => bottom_decode(msg), + _ => "something went wrong :(".to_owned(), + } + } else { + "did you forget to enter a message?".to_owned() } - - ret } pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand { -- cgit v1.2.3