diff options
Diffstat (limited to 'src/commands/meme/mod.rs')
| -rw-r--r-- | src/commands/meme/mod.rs | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs index cfe02ee..0108219 100644 --- a/src/commands/meme/mod.rs +++ b/src/commands/meme/mod.rs @@ -8,12 +8,6 @@ use serenity::{ CreateAttachment, CreateMessage, }, - framework::standard::{ - macros::group, - CommandResult, - }, - model::channel::Message, - prelude::*, }; use songbird::input::{ core::{ @@ -26,53 +20,54 @@ use songbird::input::{ Input, }; +pub use self::{ + create::*, + delete::*, + history::*, + invoke::*, +}; use crate::{ - commands::songbird, + commands::playback::songbird, db::{ Audio, Meme, }, + msg, + util, + PoiseContext, CONFIG, }; -pub use self::{ - create::*, - delete::*, - history::*, - invoke::*, -}; - mod create; mod delete; mod history; mod invoke; -#[group] -#[commands( - meme, - audio_meme, - silent_meme, - omen, - audioomen, - silentomen, - addmeme, - addaudiomeme, - delmeme, - wat, - stats, - history, - rare_meme, - memers, - query -)] -struct Memes; +pub fn commands() -> Vec<poise::Command<crate::PoiseData, anyhow::Error>> { + vec![ + meme(), + silent_meme(), + audio_meme(), + rare_meme(), + omen(), + silentomen(), + audioomen(), + addmeme(), + addaudiomeme(), + delmeme(), + history(), + stats(), + memers(), + wat(), + query(), + ] +} async fn send_meme( - ctx: &Context, + ctx: PoiseContext<'_>, t: &Meme, conn: &mut AsyncPgConnection, - msg: &Message, -) -> CommandResult { +) -> anyhow::Result<()> { let should_tts = t.content.as_ref().map(|t| !t.is_empty()).unwrap_or(false) && random::<u32>() % 25 == 0; @@ -95,12 +90,12 @@ async fn send_meme( let image = image?; let att = CreateAttachment::bytes(image.data.as_slice(), &image.filename); - msg.channel_id.send_files(ctx, vec![att], cmsg).await?; + ctx.channel_id().send_files(ctx, vec![att], cmsg).await?; }, None => { if t.content.is_some() { - msg.channel_id.send_message(ctx, cmsg).await?; + ctx.channel_id().send_message(ctx, cmsg).await?; } }, }; @@ -108,7 +103,7 @@ async fn send_meme( if let Some(audio) = audio { let audio = audio?; - let (_sb, call) = songbird(ctx, msg).await?; + let (_sb, call) = songbird(ctx).await?; let mut call = call.lock().await; if call.current_channel().is_none() { @@ -117,7 +112,7 @@ async fn send_meme( call.enqueue_input(Input::Lazy(Box::new(audio))).await; - msg.react(ctx, ReactionType::Unicode("📣".to_owned())).await?; + util::react(ctx, ReactionType::Unicode("📣".to_owned())).await?; } Ok(()) |
