diff options
Diffstat (limited to 'src/commands/meme/create.rs')
| -rw-r--r-- | src/commands/meme/create.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/commands/meme/create.rs b/src/commands/meme/create.rs index 047c556..9a89dbe 100644 --- a/src/commands/meme/create.rs +++ b/src/commands/meme/create.rs @@ -56,23 +56,24 @@ pub fn addmeme(ctx: &mut Context, msg: &Message, args: Args) -> Result<()> { let conn = connection()?; - let image = msg.attachments.first() - .ok_or(anyhow!("no attachment")) - .and_then(|att| { - let data = att.download()?; - Image::create(&conn, &att.filename, data, msg.author.id.0) - }) - .ok(); + let image = msg.attachments.first(); if image.is_none() && text.is_none() { warn!("tried to create non-audio meme with no image or text"); return ctx.send(msg.channel_id, "hahAA it's empty xdddd", msg.tts); } + let image_id = image + .ok_or(anyhow!("no attachment")) + .and_then(|att| { + let data = att.download()?; + Image::create(&conn, &att.filename, data, msg.author.id.0) + })?; + let save_result = NewMeme { title, content: text, - image_id: image, + image_id: Some(image_id), audio_id: None, metadata_id: 0, }.save(&conn, msg.author.id.0).map(|_| {}); |
