From ca46177a5df0eac30b3ca2bc33c5015e03f18688 Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Tue, 16 Jul 2019 17:22:04 -0400 Subject: restricted prefixes --- src/commands/meme/history.rs | 3 --- src/commands/mod.rs | 12 +++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/commands') diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs index 7a38325..e5f15f5 100644 --- a/src/commands/meme/history.rs +++ b/src/commands/meme/history.rs @@ -109,8 +109,6 @@ pub fn history(_: &mut Context, msg: &Message, mut args: Args) -> Result<()> { .enumerate() .rev() .map(|(i, rec)| { - use chrono; - let dt = chrono::DateTime::from_utc(rec.time, chrono::Utc{}); let ago = TIME_FORMATTER.convert((chrono::Utc::now() - dt).to_std().unwrap()); @@ -142,7 +140,6 @@ pub fn history(_: &mut Context, msg: &Message, mut args: Args) -> Result<()> { pub fn stats(_: &mut Context, msg: &Message, _: Args) -> Result<()> { use db; - use chrono; use serenity::model::{ id::UserId, user::User, diff --git a/src/commands/mod.rs b/src/commands/mod.rs index c315278..f4ff9cb 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,6 +1,6 @@ use serenity::{ framework::StandardFramework, - model::id::ChannelId, + model::id::{ChannelId, MessageId}, }; use crate::Result; @@ -151,7 +151,13 @@ fn register_db(f: StandardFramework) -> StandardFramework { f } +#[inline] pub(crate) fn send>(channel: ChannelId, text: A, tts: bool) -> Result<()> { - channel.send_message(|m| m.content(text.as_ref()).tts(tts))?; - Ok(()) + send_result(channel, text, tts).map(|_| ()) +} + +#[inline] +pub(crate) fn send_result>(channel: ChannelId, text: A, tts: bool) -> Result { + let result = channel.send_message(|m| m.content(text.as_ref()).tts(tts))?; + Ok(result.id) } -- cgit v1.3.1