diff options
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/mod.rs | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/util/mod.rs b/src/util/mod.rs index 2035054..79ab2b5 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -1,15 +1,7 @@ -use std::{ - collections::HashMap, - process::Stdio, -}; - use chrono::Duration; use grate::tracing; use lazy_static::lazy_static; -use poise::{ - CreateReply, - FrameworkError, -}; +use poise::FrameworkError; use regex::{ Match, Regex, @@ -33,6 +25,10 @@ use serenity::{ permissions::Permissions, }, }; +use std::{ + collections::HashMap, + process::Stdio, +}; use tap::Pipe; use url::Url; @@ -92,10 +88,6 @@ pub fn err_msg<'a, U, E>(err: &'a FrameworkError<U, E>) -> Option<&'a Message> { msg, .. } - | NonCommandMessage { - msg, - .. - } | DynamicPrefix { msg, .. @@ -140,17 +132,19 @@ pub async fn send( pub async fn reply<U, E>( ctx: poise::Context<'_, U, E>, text: impl AsRef<str>, -) -> Result<poise::ReplyHandle<'_>, serenity::Error> { - let handle = poise::send_reply( - ctx, - CreateReply::default() - .tts(unwrap_tts(ctx)) - .content(text.as_ref()) - .allowed_mentions(Default::default()), - ) - .await?; +) -> anyhow::Result<()> { + let msg = msg(ctx).ok_or_else(|| anyhow::anyhow!("couldn't find referenced message"))?; + + let reply = CreateMessage::new() + .reference_message(msg) + .tts(msg.tts) + .content(text.as_ref()) + .allowed_mentions(Default::default()); - Ok(handle) + let channel = ctx.guild_channel().await.ok_or_else(|| anyhow::anyhow!("not in a guild"))?; + channel.send_message(ctx.http(), reply).await?; + + Ok(()) } #[inline] |
