diff options
| author | Nathan Perry <np@nathanperry.dev> | 2021-11-03 01:56:36 -0400 |
|---|---|---|
| committer | Nathan Perry <np@nathanperry.dev> | 2021-11-03 01:56:36 -0400 |
| commit | 1cead5233b152a340aeaefdf58c1de3aebe5b62b (patch) | |
| tree | 60fbf4ab2dc944608cf3a1529183268d17edf54f | |
| parent | f59c15906229d8458844003cedbb4aac78926def (diff) | |
update, add omen
| -rw-r--r-- | Cargo.lock | 8 | ||||
| -rw-r--r-- | Cargo.toml | 6 | ||||
| -rw-r--r-- | flake.lock | 8 | ||||
| -rw-r--r-- | flake.nix | 6 | ||||
| -rw-r--r-- | src/commands/meme/invoke.rs | 8 | ||||
| -rw-r--r-- | src/db/mod.rs | 14 | ||||
| -rw-r--r-- | src/main.rs | 2 |
7 files changed, 27 insertions, 25 deletions
@@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "addr2line" version = "0.12.1" @@ -236,7 +238,7 @@ dependencies = [ [[package]] name = "command_attr" version = "0.1.6" -source = "git+https://github.com/mammothbane/serenity#df8e502d5b92c497d61c458c934fb77fc14f1d7f" +source = "git+ssh://gitea@git.nathanperry.dev/fork/serenity?branch=master#df8e502d5b92c497d61c458c934fb77fc14f1d7f" dependencies = [ "proc-macro2", "quote", @@ -1861,7 +1863,7 @@ dependencies = [ [[package]] name = "serenity" version = "0.7.5" -source = "git+https://github.com/mammothbane/serenity#df8e502d5b92c497d61c458c934fb77fc14f1d7f" +source = "git+ssh://gitea@git.nathanperry.dev/fork/serenity?branch=master#df8e502d5b92c497d61c458c934fb77fc14f1d7f" dependencies = [ "anyhow", "audiopus", @@ -2097,7 +2099,7 @@ dependencies = [ [[package]] name = "thulani" -version = "0.1.6" +version = "0.1.7" dependencies = [ "anyhow", "chrono", @@ -1,7 +1,7 @@ [package] name = "thulani" -version = "0.1.6" -authors = ["Nathan Perry <avaglir@gmail.com>"] +version = "0.1.7" +authors = ["Nathan Perry <np@nathanperry.dev>"] edition = "2018" [features] @@ -43,5 +43,5 @@ envconfig_derive = "^0.8" [dependencies.serenity] default-features = false features = ["builder", "cache", "client", "framework", "gateway", "http", "model", "utils", "voice", "standard_framework", "rustls_backend"] -git = "https://github.com/mammothbane/serenity" +git = "ssh://gitea@git.nathanperry.dev/fork/serenity" branch = "master" @@ -37,16 +37,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1611355196, - "narHash": "sha256-XVL+K2lPm/5cEx4Pe9mDyn7ok51YJK5gTjEVRnlpWFE=", + "lastModified": 1635879315, + "narHash": "sha256-yfCKg/0Cc2wKUQvb0ND5ijac8adPuDBvubJhpGemNlM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ce4a93e13a73a53028f9e86a8a8c7f21fbc93196", + "rev": "3dc6784ba46181e08df9a9b1117a512208711b09", "type": "github" }, "original": { "owner": "nixos", - "ref": "release-20.09", + "ref": "release-21.05", "repo": "nixpkgs", "type": "github" } @@ -1,6 +1,6 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/release-20.09"; + nixpkgs.url = "github:nixos/nixpkgs/release-21.05"; flake-utils.url = "github:numtide/flake-utils"; nixpkgs-mozilla = { @@ -32,8 +32,8 @@ (self: super: let rust = (super.rustChannelOf { channel = "nightly"; - date = "2021-01-01"; - sha256 = "9wp6afVeZqCOEgXxYQiryYeF07kW5IHh3fQaOKF2oRI="; + date = "2021-10-26"; + sha256 = "1hLbypXA+nuH7o3AHCokzSBZAvQxvef4x9+XxO3aBao="; }).rust.override { extensions = ["rust-src"]; }; diff --git a/src/commands/meme/invoke.rs b/src/commands/meme/invoke.rs index d0b7a19..d966d8c 100644 --- a/src/commands/meme/invoke.rs +++ b/src/commands/meme/invoke.rs @@ -32,6 +32,12 @@ pub fn meme(ctx: &mut Context, msg: &Message, args: Args) -> Result<()> { } #[command] +pub fn omen(ctx: &mut Context, msg: &Message, _args: Args) -> Result<()> { + let args = Args::new("", &[]); + _meme(ctx, msg, args, AudioPlayback::Optional) +} + +#[command] #[aliases("audiomeme", "audiomem")] pub fn audio_meme(ctx: &mut Context, msg: &Message, args: Args) -> Result<()> { _meme(ctx, msg, args, AudioPlayback::Required) @@ -120,7 +126,7 @@ pub fn rare_meme(ctx: &mut Context, msg: &Message, _args: Args) -> Result<()> { match meme { Ok(meme) => { - InvocationRecord::create(&conn, msg.author.id.0, msg.id.0, meme.id, true)?; + r InvocationRecord::create(&conn, msg.author.id.0, msg.id.0, meme.id, true)?; send_meme(ctx, &meme, &conn, msg) }, Err(e) => { diff --git a/src/db/mod.rs b/src/db/mod.rs index db6cfb8..611526f 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -215,7 +215,7 @@ pub fn rare_meme(conn: &PgConnection, audio: bool) -> Result<Meme> { let meme_id = elems.into_iter() .find(|(_, x)| target_prob < *x) - .ok_or(anyhow!("couldn't locate meme satisfying target probability"))? + .ok_or_else(|| anyhow!("couldn't locate meme satisfying target probability"))? .0; Meme::find(conn, meme_id) @@ -223,7 +223,6 @@ pub fn rare_meme(conn: &PgConnection, audio: bool) -> Result<Meme> { pub fn rand_meme(conn: &PgConnection, audio: bool) -> Result<Meme> { use rand::{thread_rng, seq::SliceRandom}; - use std::ops::Try; let ids: Vec<i32> = if audio { memes::table @@ -243,8 +242,7 @@ pub fn rand_meme(conn: &PgConnection, audio: bool) -> Result<Meme> { }; let id = ids.choose(&mut thread_rng()) - .into_result() - .map_err( |_| anyhow!("couldn't load meme"))?; + .ok_or_else(|| anyhow!("couldn't load meme"))?; memes::table .find(id) @@ -254,7 +252,6 @@ pub fn rand_meme(conn: &PgConnection, audio: bool) -> Result<Meme> { pub fn rand_audio_meme(conn: &PgConnection) -> Result<Meme> { use rand::{thread_rng, seq::SliceRandom}; - use std::ops::Try; let ids: Vec<i32> = memes::table .select(memes::id) @@ -263,8 +260,7 @@ pub fn rand_audio_meme(conn: &PgConnection) -> Result<Meme> { .map_err(Error::from)?; let id = ids.choose(&mut thread_rng()) - .into_result() - .map_err(|_| anyhow!("couldn't load audio meme"))?; + .ok_or_else(|| anyhow!("couldn't load audio meme"))?; memes::table .find(id) @@ -274,7 +270,6 @@ pub fn rand_audio_meme(conn: &PgConnection) -> Result<Meme> { pub fn rand_silent_meme(conn: &PgConnection) -> Result<Meme> { use rand::{thread_rng, seq::SliceRandom}; - use std::ops::Try; let ids: Vec<i32> = memes::table .select(memes::id) @@ -283,8 +278,7 @@ pub fn rand_silent_meme(conn: &PgConnection) -> Result<Meme> { .map_err(Error::from)?; let id = ids.choose(&mut thread_rng()) - .into_result() - .map_err(|_| anyhow!("couldn't load audio meme"))?; + .ok_or_else(|| anyhow!("couldn't load audio meme"))?; memes::table .find(id) diff --git a/src/main.rs b/src/main.rs index 259a652..eebc726 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -#![feature(try_trait)] +#![feature(try_trait_v2)] #![feature(pattern)] #![feature(concat_idents)] #![feature(associated_type_defaults)] |
