diff options
| author | Nathan Perry <np@nathanperry.dev> | 2019-11-17 21:31:28 -0500 |
|---|---|---|
| committer | Nathan Perry <np@nathanperry.dev> | 2019-11-17 21:31:28 -0500 |
| commit | 2a38c282dd57c2051a568549d62c80d6036e8920 (patch) | |
| tree | ec25f84dda5cdb100ae093b0a690ef349636b4dc /src/commands/meme/delete.rs | |
| parent | 479bb8d584b138054acc6567b72cb3076832e79c (diff) | |
most restructuring done
Diffstat (limited to 'src/commands/meme/delete.rs')
| -rw-r--r-- | src/commands/meme/delete.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/commands/meme/delete.rs b/src/commands/meme/delete.rs index 5c6eb13..72226e5 100644 --- a/src/commands/meme/delete.rs +++ b/src/commands/meme/delete.rs @@ -9,25 +9,28 @@ use serenity::{ }; use crate::{ - commands::send, db::{ connection, delete_meme, }, Result, + util::CtxExt, }; -pub fn delmeme(_: &mut Context, msg: &Message, mut args: Args) -> Result<()> { +#[command] +#[aliases("delmem")] +pub fn delmeme(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> { let title = args.single_quoted::<String>()?; let conn = connection()?; + match delete_meme(&conn, &title, msg.author.id.0) { - Ok(_) => msg.react("💀"), + Ok(_) => msg.react(ctx, "💀"), Err(e) => { if let Some(NotFound) = e.downcast_ref::<DieselError>() { - msg.react("❓")?; + msg.react(ctx, "❓")?; info!("attempted to delete nonexistent meme: '{}'", title); - send(msg.channel_id, "nice try", msg.tts)?; + ctx.send(msg.channel_id, "nice try", msg.tts)?; return Ok(()); } |
