summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/ask.rs4
-rw-r--r--src/commands/bottom.rs22
-rw-r--r--src/commands/convert.rs22
-rw-r--r--src/commands/copypasta.rs2
-rw-r--r--src/commands/random_lore.rs4
5 files changed, 25 insertions, 29 deletions
diff --git a/src/commands/ask.rs b/src/commands/ask.rs
index 6188f43..b0b24f3 100644
--- a/src/commands/ask.rs
+++ b/src/commands/ask.rs
@@ -3,8 +3,8 @@ use serenity::builder::CreateApplicationCommand;
use serenity::model::prelude::command::CommandOptionType;
use serenity::model::prelude::interaction::application_command::CommandDataOption;
-pub async fn run(_: &[CommandDataOption]) -> String {
- utils::get_random_response().await
+pub fn run(_: &[CommandDataOption]) -> String {
+ utils::get_random_response()
}
pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
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 {
diff --git a/src/commands/convert.rs b/src/commands/convert.rs
index 6fe141d..8f8c424 100644
--- a/src/commands/convert.rs
+++ b/src/commands/convert.rs
@@ -5,7 +5,7 @@ use serenity::model::prelude::interaction::application_command::{
CommandDataOption, CommandDataOptionValue,
};
-pub async fn run(options: &[CommandDataOption]) -> String {
+pub fn run(options: &[CommandDataOption]) -> String {
let err = "couldn't get convert subcommand!";
let data = options
.get(0)
@@ -20,19 +20,21 @@ pub async fn run(options: &[CommandDataOption]) -> String {
.as_ref()
.expect("failed to resolve string!");
- let mut ret = 0.0;
- if let CommandDataOptionValue::Number(number) = option {
+ let temp = if let &CommandDataOptionValue::Number(number) = option {
match subcommand {
- "fahrenheit" => ret = utils::celsius_to_fahrenheit(number).await,
- "celsius" => ret = utils::fahrenheit_to_celsius(number).await,
- _ => ret = 0.0,
- };
+ "fahrenheit" => Some(utils::celsius_to_fahrenheit(number)),
+ "celsius" => Some(utils::fahrenheit_to_celsius(number)),
+ _ => None,
+ }
+ } else {
+ None
};
- if ret == 0.0 {
- return "couldn't figure it out oops".to_string();
+ if let Some(temp) = temp {
+ format!("{temp:.2}")
+ } else {
+ "couldn't figure it out oops".to_owned()
}
- format!("{:.2}", ret)
}
pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
diff --git a/src/commands/copypasta.rs b/src/commands/copypasta.rs
index ec3f3c6..670a5df 100644
--- a/src/commands/copypasta.rs
+++ b/src/commands/copypasta.rs
@@ -18,7 +18,7 @@ pub async fn run(options: &[CommandDataOption], channel_id: ChannelId, http: &Ar
.expect(err_msg);
if let CommandDataOptionValue::String(copypasta) = option {
- let replies = utils::get_copypasta(copypasta).await;
+ let replies = utils::get_copypasta(copypasta);
if replies.len() > 1 {
for reply in replies {
diff --git a/src/commands/random_lore.rs b/src/commands/random_lore.rs
index 345f753..b07660e 100644
--- a/src/commands/random_lore.rs
+++ b/src/commands/random_lore.rs
@@ -2,8 +2,8 @@ use crate::utils::get_random_lore;
use serenity::builder::CreateApplicationCommand;
use serenity::model::prelude::interaction::application_command::CommandDataOption;
-pub async fn run(_: &[CommandDataOption]) -> String {
- get_random_lore().await
+pub fn run(_: &[CommandDataOption]) -> String {
+ get_random_lore()
}
pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {