diff options
Diffstat (limited to 'src/commands/meme/invoke.rs')
| -rw-r--r-- | src/commands/meme/invoke.rs | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/commands/meme/invoke.rs b/src/commands/meme/invoke.rs index c5ca502..de0272f 100644 --- a/src/commands/meme/invoke.rs +++ b/src/commands/meme/invoke.rs @@ -38,6 +38,18 @@ pub fn omen(ctx: &mut Context, msg: &Message, _args: Args) -> Result<()> { } #[command] +pub fn silentomen(ctx: &mut Context, msg: &Message, _args: Args) -> Result<()> { + let args = Args::new("", &[]); + _meme(ctx, msg, args, AudioPlayback::Prohibited) +} + +#[command] +pub fn audioomen(ctx: &mut Context, msg: &Message, _args: Args) -> Result<()> { + let args = Args::new("", &[]); + _meme(ctx, msg, args, AudioPlayback::Required) +} + +#[command] #[aliases("audiomeme", "audiomem")] pub fn audio_meme(ctx: &mut Context, msg: &Message, args: Args) -> Result<()> { _meme(ctx, msg, args, AudioPlayback::Required) @@ -63,10 +75,10 @@ fn _meme(ctx: &mut Context, msg: &Message, args: Args, audio_playback: AudioPlay let search = args.raw().join(" "); - let conn = connection()?; - let mem = match find_meme(&conn, search) { + let mut conn = connection()?; + let mem = match find_meme(&mut conn, search) { Ok(x) => { - InvocationRecord::create(&conn, msg.author.id.0, msg.id.0, x.id, false)?; + InvocationRecord::create(&mut conn, msg.author.id.0, msg.id.0, x.id, false)?; x }, @@ -81,24 +93,24 @@ fn _meme(ctx: &mut Context, msg: &Message, args: Args, audio_playback: AudioPlay }, }; - send_meme(ctx, &mem, &conn, msg) + send_meme(ctx, &mem, &mut conn, msg) } fn rand_meme(ctx: &Context, message: &Message, audio_playback: AudioPlayback) -> Result<()> { - let conn = connection()?; + let mut conn = connection()?; let should_audio = ctx.users_listening()?; let mem = match audio_playback { - AudioPlayback::Required => db::rand_audio_meme(&conn), - AudioPlayback::Optional => db::rand_meme(&conn, should_audio), - AudioPlayback::Prohibited => db::rand_silent_meme(&conn), + AudioPlayback::Required => db::rand_audio_meme(&mut conn), + AudioPlayback::Optional => db::rand_meme(&mut conn, should_audio), + AudioPlayback::Prohibited => db::rand_silent_meme(&mut conn), }; match mem { Ok(mem) => { - InvocationRecord::create(&conn, message.author.id.0, message.id.0, mem.id, true)?; - send_meme(ctx, &mem, &conn, message)?; + InvocationRecord::create(&mut conn, message.author.id.0, message.id.0, mem.id, true)?; + send_meme(ctx, &mem, &mut conn, message)?; Ok(()) }, Err(e) => { @@ -121,13 +133,13 @@ fn rand_meme(ctx: &Context, message: &Message, audio_playback: AudioPlayback) -> pub fn rare_meme(ctx: &mut Context, msg: &Message, _args: Args) -> Result<()> { let should_audio = ctx.users_listening()?; - let conn = connection()?; - let meme = db::rare_meme(&conn, should_audio); + let mut conn = connection()?; + let meme = db::rare_meme(&mut conn, should_audio); match meme { Ok(meme) => { - InvocationRecord::create(&conn, msg.author.id.0, msg.id.0, meme.id, true)?; - send_meme(ctx, &meme, &conn, msg) + InvocationRecord::create(&mut conn, msg.author.id.0, msg.id.0, meme.id, true)?; + send_meme(ctx, &meme, &mut conn, msg) }, Err(e) => { match e.downcast_ref::<DieselError>() { |
