summaryrefslogtreecommitdiff
path: root/src/commands/random_lore.rs
diff options
context:
space:
mode:
authorseth <[email protected]>2023-07-10 00:18:36 -0400
committerseth <[email protected]>2023-11-16 00:35:07 +0000
commita4a9353e1c8f902b7d7b3cf74e3e5b129c214330 (patch)
treeb58da1d30af52e97c0251e0d6882cd0ccdfeb20a /src/commands/random_lore.rs
parent5e9ec7f008e01d25c0b7f782c5ae043bc9ca0933 (diff)
start using poise
Diffstat (limited to 'src/commands/random_lore.rs')
-rw-r--r--src/commands/random_lore.rs25
1 files changed, 14 insertions, 11 deletions
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)
+ }
+ }
}