summaryrefslogtreecommitdiff
path: root/src/commands/random.rs
diff options
context:
space:
mode:
authorseth <[email protected]>2023-11-30 22:18:51 -0500
committerseth <[email protected]>2023-12-01 07:12:49 -0500
commit76c0f94e6d7aa108424b34826eb7d8514b026287 (patch)
tree7315bd6dfe52c158041bed64ba39781718a69335 /src/commands/random.rs
parentdb52e639b85d79bed870020aec7a045851ca5ee3 (diff)
feat: use eyre, better logging, & refactor
small commits be damned
Diffstat (limited to 'src/commands/random.rs')
-rw-r--r--src/commands/random.rs42
1 files changed, 14 insertions, 28 deletions
diff --git a/src/commands/random.rs b/src/commands/random.rs
index bc34928..9595d09 100644
--- a/src/commands/random.rs
+++ b/src/commands/random.rs
@@ -1,44 +1,30 @@
-use crate::{api, consts, utils, Context, Error};
+use crate::{api, consts, utils, Context};
+
+use color_eyre::eyre::Result;
#[poise::command(slash_command, subcommands("lore", "teawie", "shiggy"))]
-pub async fn random(_ctx: Context<'_>) -> Result<(), Error> {
+pub async fn random(_ctx: Context<'_>) -> Result<()> {
Ok(())
}
/// get a random piece of teawie lore!
#[poise::command(prefix_command, slash_command)]
-pub async fn 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)
- }
- }
+pub async fn lore(ctx: Context<'_>) -> Result<()> {
+ let resp = utils::random_choice(consts::LORE)?;
+ ctx.say(resp).await?;
+ Ok(())
}
/// get a random teawie
#[poise::command(prefix_command, slash_command)]
-pub async fn teawie(ctx: Context<'_>) -> Result<(), Error> {
- if let Ok(url) = api::guzzle::get_random_teawie().await {
- utils::send_url_as_embed(ctx, url).await
- } else {
- ctx.say("i'm too lazy to send a selfie right now :(")
- .await?;
- Ok(())
- }
+pub async fn teawie(ctx: Context<'_>) -> Result<()> {
+ let url = api::guzzle::get_random_teawie().await?;
+ utils::send_url_as_embed(ctx, url).await
}
/// get a random shiggy
#[poise::command(prefix_command, slash_command)]
-pub async fn shiggy(ctx: Context<'_>) -> Result<(), Error> {
- if let Ok(url) = api::shiggy::get_random_shiggy().await {
- utils::send_url_as_embed(ctx, url).await
- } else {
- ctx.say("i couldn't get a shiggy right now :(").await?;
- Ok(())
- }
+pub async fn shiggy(ctx: Context<'_>) -> Result<()> {
+ let url = api::shiggy::get_random_shiggy().await?;
+ utils::send_url_as_embed(ctx, url).await
}