aboutsummaryrefslogtreecommitdiff
path: root/src/commands/meme/mod.rs
diff options
context:
space:
mode:
authorNathan Perry <np@nathanperry.dev>2019-11-17 23:51:56 -0500
committerNathan Perry <np@nathanperry.dev>2019-11-17 23:51:56 -0500
commit8a5a841e619793ce81b177179694712284be23e4 (patch)
tree6e8b46b1a008a94236e5aaaf48fad95dee70451a /src/commands/meme/mod.rs
parentc068e82d2b6341cf7896bfc2e1fd4683f28d67b4 (diff)
borrowck fixes
Diffstat (limited to 'src/commands/meme/mod.rs')
-rw-r--r--src/commands/meme/mod.rs29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs
index 1761ab1..93de288 100644
--- a/src/commands/meme/mod.rs
+++ b/src/commands/meme/mod.rs
@@ -2,7 +2,6 @@ use diesel::PgConnection;
use log::debug;
use rand::{Rng, thread_rng};
use serenity::{
- builder::CreateMessage,
framework::standard::macros::group,
http::AttachmentType,
model::channel::Message,
@@ -60,24 +59,30 @@ fn send_meme(ctx: &Context, t: &Meme, conn: &PgConnection, msg: &Message) -> Res
let image = t.image(conn);
let audio = t.audio(conn);
- let create_msg = |m: &mut CreateMessage| {
- let ret = m.tts(should_tts);
-
- match t.content {
- Some(ref text) if text.len() > 0 => ret.content(text),
- _ => ret,
- }
- };
-
match image {
Some(image) => {
let image = image?;
- msg.channel_id.send_files(ctx, vec!(AttachmentType::Bytes((&image.data, &image.filename))), create_msg)?;
+ msg.channel_id.send_files(ctx, vec!(AttachmentType::Bytes((&image.data, &image.filename))), |m| {
+ let ret = m.tts(should_tts);
+
+ match t.content {
+ Some(ref text) if text.len() > 0 => ret.content(text),
+ _ => ret,
+ }
+ })?;
},
None => match t.content {
- Some(_) => { msg.channel_id.send_message(ctx, create_msg)?; },
+ Some(_) => { msg.channel_id.send_message(ctx, |m| {
+ let ret = m.tts(should_tts);
+
+ match t.content {
+ Some(ref text) if text.len() > 0 => ret.content(text),
+ _ => ret,
+ }
+ })?; },
None => {},
+
},
};