aboutsummaryrefslogtreecommitdiff
path: root/src/commands/meme/delete.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/meme/delete.rs')
-rw-r--r--src/commands/meme/delete.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/commands/meme/delete.rs b/src/commands/meme/delete.rs
index 7eafc80..c06e9d0 100644
--- a/src/commands/meme/delete.rs
+++ b/src/commands/meme/delete.rs
@@ -1,45 +1,49 @@
use diesel::{
- NotFound,
result::Error as DieselError,
+ NotFound,
};
use log::info;
use serenity::{
+ all::ReactionType,
framework::standard::{
- Args,
macros::command,
+ Args,
+ CommandResult,
},
model::channel::Message,
prelude::*,
};
use crate::{
- Result,
db::{
connection,
delete_meme,
},
- util::CtxExt,
+ util,
};
#[command]
#[aliases("delmem")]
-pub fn delmeme(ctx: &mut Context, msg: &Message, mut args: Args) -> Result<()> {
+pub async fn delmeme(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let title = args.single_quoted::<String>()?;
let mut conn = connection()?;
- match delete_meme(&mut conn, &title, msg.author.id.0) {
- Ok(_) => msg.react(ctx, "💀"),
+ match delete_meme(&mut conn, &title, msg.author.id.get()) {
+ Ok(_) => {
+ msg.react(ctx, ReactionType::Unicode("💀".to_owned())).await?;
+ Ok(())
+ },
Err(e) => {
if let Some(NotFound) = e.downcast_ref::<DieselError>() {
- msg.react(&ctx, "❓")?;
+ msg.react(&ctx, ReactionType::Unicode("❓".to_owned())).await?;
info!("attempted to delete nonexistent meme: '{}'", title);
- ctx.send(msg.channel_id, "nice try", msg.tts)?;
+ util::send(ctx, msg.channel_id, "nice try", msg.tts).await?;
return Ok(());
}
Err(e)?;
Ok(())
- }
+ },
}
}