aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorNathan Perry <avaglir@gmail.com>2019-04-09 03:56:35 -0400
committerNathan Perry <avaglir@gmail.com>2019-04-09 03:56:35 -0400
commitfcf5e989f995484987b3474494a8de5ca23d1633 (patch)
treebb61cc970089413b3209c67cfaf89c91d166a6a3 /src/commands
parent74bd3dfdd7c57beb2bc84b6abaabd514558cba5d (diff)
implement `memers` command
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/meme/history.rs33
-rw-r--r--src/commands/mod.rs5
2 files changed, 38 insertions, 0 deletions
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::<Result<Vec<_>>>()?
+ .into_iter()
+ .join("\n");
+
+ send(msg.channel_id, &s, msg.tts)
+} \ No newline at end of file
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 74e6e3f..3ceb15f 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -134,6 +134,11 @@ fn register_db(f: StandardFramework) -> StandardFramework {
.desc("deliver an underutilized meme")
.cmd(rare_meme)
)
+ .command("memers", |c| c
+ .guild_only(true)
+ .desc("list stats for all server memers")
+ .cmd(memers)
+ )
}
#[cfg(not(feature = "diesel"))]