From a4a9353e1c8f902b7d7b3cf74e3e5b129c214330 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 10 Jul 2023 00:18:36 -0400 Subject: start using poise --- src/commands/random_lore.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/commands/random_lore.rs') diff --git a/src/commands/random_lore.rs b/src/commands/random_lore.rs index b07660e..875a35e 100644 --- a/src/commands/random_lore.rs +++ b/src/commands/random_lore.rs @@ -1,13 +1,16 @@ -use crate::utils::get_random_lore; -use serenity::builder::CreateApplicationCommand; -use serenity::model::prelude::interaction::application_command::CommandDataOption; +use crate::{consts, utils, Context, Error}; -pub fn run(_: &[CommandDataOption]) -> String { - get_random_lore() -} - -pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand { - command - .name("random_lore") - .description("get a random piece of teawie lore!") +/// get a random piece of teawie lore! +#[poise::command(prefix_command, slash_command)] +pub async fn random_lore(ctx: Context<'_>) -> Result<(), Error> { + match utils::random_choice(consts::LORE) { + Ok(resp) => { + ctx.say(resp).await?; + Ok(()) + } + Err(why) => { + ctx.say("i can't think of any right now :(").await?; + Err(why) + } + } } -- cgit v1.2.3