From fcf5e989f995484987b3474494a8de5ca23d1633 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Tue, 9 Apr 2019 03:56:35 -0400 Subject: implement `memers` command --- src/commands/meme/history.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/commands/meme') diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs index 43deee3..ea79ecc 100644 --- a/src/commands/meme/history.rs +++ b/src/commands/meme/history.rs @@ -202,3 +202,36 @@ and *{}* was the most-memed overall ({})"#, ); send(msg.channel_id, s, msg.tts) } + +pub fn memers(_: &mut Context, msg: &Message, _args: Args) -> Result<()> { + use db; + use itertools::Itertools; + use serenity::model::{ + id::UserId, + }; + use crate::TARGET_GUILD_ID; + + let s = db::memers()? + .into_iter() + .map(|info| { + let user = UserId(info.user_id).to_user()?; + let username = user.nick_in(*TARGET_GUILD_ID).unwrap_or(user.name); + + let res = format!( + "**{}**: {} total, {} random, {} specific. favorite meme: *{}* ({})", + username, + info.random_memes + info.specific_memes, + info.random_memes, + info.specific_memes, + info.most_used_meme, + info.most_used_meme_count, + ); + + Ok(res) + }) + .collect::>>()? + .into_iter() + .join("\n"); + + send(msg.channel_id, &s, msg.tts) +} \ No newline at end of file -- cgit v1.3.1