From 76c0f94e6d7aa108424b34826eb7d8514b026287 Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 30 Nov 2023 22:18:51 -0500 Subject: feat: use eyre, better logging, & refactor small commits be damned --- src/commands/copypasta.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/commands/copypasta.rs') diff --git a/src/commands/copypasta.rs b/src/commands/copypasta.rs index 14a6673..313cd13 100644 --- a/src/commands/copypasta.rs +++ b/src/commands/copypasta.rs @@ -1,7 +1,8 @@ -use crate::{utils, Context, Error}; +use crate::{utils, Context}; use std::collections::HashMap; +use color_eyre::eyre::{eyre, Result}; use include_dir::{include_dir, Dir}; use log::*; @@ -58,8 +59,11 @@ fn get_copypasta(name: Copypastas) -> String { pub async fn copypasta( ctx: Context<'_>, #[description = "the copypasta you want to send"] copypasta: Copypastas, -) -> Result<(), Error> { - let gid = ctx.guild_id().unwrap_or_default(); +) -> Result<()> { + let gid = ctx + .guild_id() + .ok_or_else(|| eyre!("couldnt get guild from message!"))?; + if !utils::is_guild_allowed(gid) { info!("not running copypasta command in {gid}"); return Ok(()); -- cgit v1.2.3