diff options
| author | Nathan Perry <avaglir@gmail.com> | 2019-03-02 23:01:37 -0500 |
|---|---|---|
| committer | Nathan Perry <avaglir@gmail.com> | 2019-03-02 23:01:37 -0500 |
| commit | bbdf68cad0966ca89dab3ffb0aef5c0d3bfe8789 (patch) | |
| tree | cb3a9ff9108ad1e704d7005d62035b55b6c192ed /src/commands/meme.rs | |
| parent | 39065a2240f7e0ee1ab23b6d8622e8ac48a33a32 (diff) | |
add stats command
Diffstat (limited to 'src/commands/meme.rs')
| -rw-r--r-- | src/commands/meme.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/commands/meme.rs b/src/commands/meme.rs index a1b0671..f83b793 100644 --- a/src/commands/meme.rs +++ b/src/commands/meme.rs @@ -244,8 +244,21 @@ pub fn delmeme(_: &mut Context, msg: &Message, mut args: Args) -> Result<()> { msg.react("💀") } -pub fn renamememe(_: &mut Context, msg: &Message, _: Args) -> Result<()> { - send(msg.channel_id, "hwaet", msg.tts) +pub fn stats(_: &mut Context, msg: &Message, _: Args) -> Result<()> { + use db; + + let conn = connection()?; + let stats = db::stats(&conn)?; + + let s = format!( + "{} memes total\n{} memes with audio ({:0.1}%)\n{} memes with images ({:0.1}%)", + stats.memes_overall, + stats.audio_memes, + (stats.audio_memes as f64) / (stats.memes_overall as f64) * 100., + stats.image_memes, + (stats.image_memes as f64) / (stats.memes_overall as f64) * 100., + ); + send(msg.channel_id, s, msg.tts) } fn rand_meme(ctx: &Context, message: &Message, audio_only: bool) -> Result<()> { |
