diff options
Diffstat (limited to 'src/commands/meme/delete.rs')
| -rw-r--r-- | src/commands/meme/delete.rs | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/commands/meme/delete.rs b/src/commands/meme/delete.rs index 6af1b6b..25ddf0d 100644 --- a/src/commands/meme/delete.rs +++ b/src/commands/meme/delete.rs @@ -3,42 +3,33 @@ use diesel::{ NotFound, }; use log::info; -use serenity::{ - all::ReactionType, - framework::standard::{ - macros::command, - Args, - CommandResult, - }, - model::channel::Message, - prelude::*, -}; +use serenity::all::ReactionType; use crate::{ db::{ connection, delete_meme, }, + msg, util, + PoiseContext, }; -#[command] -#[aliases("delmem")] -pub async fn delmeme(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { - let title = args.single_quoted::<String>()?; - +#[poise::command(slash_command, prefix_command, guild_only, category = "memes", aliases("delmem"))] +pub async fn delmeme(ctx: PoiseContext<'_>, title: String) -> anyhow::Result<()> { let mut conn = connection().await?; - match delete_meme(&mut conn, &title, msg.author.id.get()).await { + match delete_meme(&mut conn, &title, ctx.author().id.get()).await { Ok(_) => { - msg.react(ctx, ReactionType::Unicode("💀".to_owned())).await?; + util::react(ctx, ReactionType::Unicode("💀".to_owned())).await?; Ok(()) }, Err(e) => { if let Some(NotFound) = e.downcast_ref::<DieselError>() { - msg.react(&ctx, ReactionType::Unicode("❓".to_owned())).await?; info!("attempted to delete nonexistent meme: '{}'", title); - util::send(ctx, msg.channel_id, "nice try", msg.tts).await?; + + util::react(ctx, ReactionType::Unicode("❓".to_owned())).await?; + util::reply(ctx, "nice try").await?; return Ok(()); } |
