diff options
| author | seth <[email protected]> | 2023-07-10 00:18:36 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2023-11-16 00:35:07 +0000 |
| commit | a4a9353e1c8f902b7d7b3cf74e3e5b129c214330 (patch) | |
| tree | b58da1d30af52e97c0251e0d6882cd0ccdfeb20a /src/commands/ask.rs | |
| parent | 5e9ec7f008e01d25c0b7f782c5ae043bc9ca0933 (diff) | |
start using poise
Diffstat (limited to 'src/commands/ask.rs')
| -rw-r--r-- | src/commands/ask.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/commands/ask.rs b/src/commands/ask.rs index b0b24f3..5075b9d 100644 --- a/src/commands/ask.rs +++ b/src/commands/ask.rs @@ -1,21 +1,23 @@ -use crate::utils; -use serenity::builder::CreateApplicationCommand; -use serenity::model::prelude::command::CommandOptionType; -use serenity::model::prelude::interaction::application_command::CommandDataOption; +use crate::consts; +use crate::utils::random_choice; +use crate::{Context, Error}; -pub fn run(_: &[CommandDataOption]) -> String { - utils::get_random_response() -} - -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) - }) +/// ask teawie a question! +#[poise::command(prefix_command, slash_command)] +pub async fn ask( + ctx: Context<'_>, + #[description = "the question you want to ask teawie"] + #[rename = "question"] + _question: String, +) -> Result<(), Error> { + match random_choice(consts::RESPONSES) { + Ok(resp) => { + ctx.say(resp).await?; + Ok(()) + } + Err(why) => { + ctx.say("idk").await?; + Err(why) + } + } } |
