Check inbox status on name change

This commit is contained in:
kageru 2021-07-20 20:31:58 +02:00
parent 4eaae45f5f
commit f7f8ca39aa
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -1,6 +1,5 @@
use async_trait::async_trait;
use inbox::*;
use itertools::Itertools;
use lazy_static::lazy_static;
use serenity::client::Client;
use serenity::framework::standard::{
@ -98,6 +97,20 @@ async fn name(ctx: &Context, msg: &Message) -> CommandResult {
msg.author.id,
now.unix_timestamp()
);
if msg.author.id == INBOX_OWNER {
let msg_count = INBOX.count_messages("name");
if msg_count > 0 {
send_or_log!(
msg.reply(&ctx, format!("{} neue Nachrichten für {}", msg_count, name))
.await
);
} else {
send_or_log!(
msg.reply(&ctx, format!("Keine neuen Nachrichten für {}", name))
.await
);
}
}
} else {
send_or_log!(msg.reply(&ctx, "Please specify a new name.").await);
}