diff options
Diffstat (limited to 'src/commands')
| -rw-r--r-- | src/commands/ask.rs | 21 | ||||
| -rw-r--r-- | src/commands/copypasta.rs | 66 | ||||
| -rw-r--r-- | src/commands/mod.rs | 3 | ||||
| -rw-r--r-- | src/commands/random_teawie.rs | 13 |
4 files changed, 103 insertions, 0 deletions
diff --git a/src/commands/ask.rs b/src/commands/ask.rs new file mode 100644 index 0000000..6188f43 --- /dev/null +++ b/src/commands/ask.rs @@ -0,0 +1,21 @@ +use crate::utils; +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 register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand { + command + .name("ask") + .description("ask lord teawie a question and they shall respond") + .create_option(|option| { + option + .name("question") + .description("the question you want to ask teawie") + .kind(CommandOptionType::String) + .required(true) + }) +} diff --git a/src/commands/copypasta.rs b/src/commands/copypasta.rs new file mode 100644 index 0000000..9424665 --- /dev/null +++ b/src/commands/copypasta.rs @@ -0,0 +1,66 @@ +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 { + let err_msg = "expected a copyasta"; + let option = options + .get(0) + .expect(err_msg) + .resolved + .as_ref() + .expect(err_msg); + + if let CommandDataOptionValue::String(copypasta) = option { + let replies = &utils::get_copypasta(copypasta).await; + let len = replies.len() - 1; + + // 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; + + match resp { + Ok(_) => continue, + Err(why) => { + println!("couldn't send message: {:?}", why); + } + } + } + } + + return replies[len].to_string(); + } + + "couldn't find a copypasta".to_string() +} + +pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand { + command + .name("copypasta") + .description("send funni copypasta") + .create_option(|option| { + option + .name("copypasta") + .description("the copypasta you want to send") + .kind(CommandOptionType::String) + .required(true) + // .add_string_choice("ismah", "ismah") // renable this later + .add_string_choice("happymeal", "happymeal") + .add_string_choice("sus", "sus") + .add_string_choice("ticktock", "ticktock") + .add_string_choice("egrill", "egrill") + .add_string_choice("dvd", "dvd") + .add_string_choice("twitter", "twitter") + }) +} diff --git a/src/commands/mod.rs b/src/commands/mod.rs new file mode 100644 index 0000000..d3ec259 --- /dev/null +++ b/src/commands/mod.rs @@ -0,0 +1,3 @@ +pub mod ask; +pub mod copypasta; +pub mod random_teawie; diff --git a/src/commands/random_teawie.rs b/src/commands/random_teawie.rs new file mode 100644 index 0000000..b3c433d --- /dev/null +++ b/src/commands/random_teawie.rs @@ -0,0 +1,13 @@ +use crate::api::guzzle::get_random_teawie; +use serenity::builder::CreateApplicationCommand; +use serenity::model::prelude::interaction::application_command::CommandDataOption; + +pub async fn run(_: &[CommandDataOption]) -> String { + get_random_teawie().await +} + +pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand { + command + .name("random_teawie") + .description("get a random teawie!") +} |
