summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/copypasta.rs23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/commands/copypasta.rs b/src/commands/copypasta.rs
index 9424665..0e1a8e6 100644
--- a/src/commands/copypasta.rs
+++ b/src/commands/copypasta.rs
@@ -1,13 +1,11 @@
use crate::utils;
use serenity::builder::CreateApplicationCommand;
use serenity::http::client::Http;
-use serenity::model::channel::Message;
use serenity::model::id::ChannelId;
use serenity::model::prelude::command::CommandOptionType;
use serenity::model::prelude::interaction::application_command::{
CommandDataOption, CommandDataOptionValue,
};
-use serenity::prelude::SerenityError;
use std::sync::Arc;
pub async fn run(options: &[CommandDataOption], channel_id: ChannelId, http: &Arc<Http>) -> String {
@@ -20,26 +18,25 @@ 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 len = replies.len() - 1;
+ let replies = utils::get_copypasta(copypasta).await;
- // send messages separately if we have > 1
- for (i, reply) in replies.iter().enumerate() {
- let resp: Result<Message, SerenityError>;
-
- if i < len {
- resp = channel_id.send_message(&http, |m| m.content(reply)).await;
+ if replies.len() > 1 {
+ for reply in replies {
+ let resp = channel_id.send_message(&http, |m| m.content(reply)).await;
match resp {
Ok(_) => continue,
Err(why) => {
println!("couldn't send message: {:?}", why);
+ "something went wrong!";
}
}
}
+ return "here's your copypasta:".to_string(); // yes this causes the
+ // application to not respond.
+ // no i don't care.
}
-
- return replies[len].to_string();
+ return replies[0].to_string();
}
"couldn't find a copypasta".to_string()
@@ -55,7 +52,7 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio
.description("the copypasta you want to send")
.kind(CommandOptionType::String)
.required(true)
- // .add_string_choice("ismah", "ismah") // renable this later
+ .add_string_choice("ismah", "ismah") // renable this later
.add_string_choice("happymeal", "happymeal")
.add_string_choice("sus", "sus")
.add_string_choice("ticktock", "ticktock")