aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorFuwn <[email protected]>2020-11-04 20:42:40 -0800
committerFuwn <[email protected]>2020-11-04 20:42:40 -0800
commited4bf9cb63576c89cad9179d9de3e0e2dd67a8ea (patch)
tree9883d6cfbe7f9f0e5708e0b0cfc3b9fcac096549 /src/core
parentfix: parse for mentions not just @everyone (diff)
downloaddep-core-next-ed4bf9cb63576c89cad9179d9de3e0e2dd67a8ea.tar.xz
dep-core-next-ed4bf9cb63576c89cad9179d9de3e0e2dd67a8ea.zip
fix: mention handling where it should be handled
Diffstat (limited to 'src/core')
-rw-r--r--src/core/consts.rs6
-rw-r--r--src/core/utils.rs10
2 files changed, 15 insertions, 1 deletions
diff --git a/src/core/consts.rs b/src/core/consts.rs
index df214c5..35da1af 100644
--- a/src/core/consts.rs
+++ b/src/core/consts.rs
@@ -1,5 +1,5 @@
use crate::db::Database;
-use serenity::model::id::{GuildId, ChannelId, RoleId};
+use serenity::model::id::{GuildId, ChannelId, RoleId, UserId};
lazy_static!{
pub static ref DB: Database = Database::connect();
@@ -31,6 +31,8 @@ pub const GUILD_LOG: ChannelId = ChannelId(770117277416554526); // 40611549
pub const NOW_LIVE: RoleId = RoleId(370395740406546432);
pub const SUPPORT_SERVER: GuildId = GuildId(704032355987488791); // 373561057639268352
pub const TRANSCEND: GuildId = GuildId(348660188951216129);
+pub const BOT_ID: UserId = UserId(712088369206919269);
+pub const BOT_BETA_ID: UserId = UserId(772434317841530882);
pub const SUPPORT_SERV_INVITE: &str = "https://discord.gg/ASrM7p9";
pub const BOT_INVITE: &str = "https://discordapp.com/oauth2/authorize/?permissions=335670488&scope=bot&client_id=712088369206919269";
@@ -54,3 +56,5 @@ pub const GUILDID_FAIL: &str = "Failed to get GuildId";
pub const MEMBER_FAIL: &str = "Failed to get member";
pub const TC_FAIL: &str = "Failed to get TimerClient";
pub const USER_FAIL: &str = "Failed to get user";
+
+pub const MENTION_FAIL: &str = "Sorry, but it seems to me that you are mentioning someone where you aren't allowed to.";
diff --git a/src/core/utils.rs b/src/core/utils.rs
index 2fb690b..2a79366 100644
--- a/src/core/utils.rs
+++ b/src/core/utils.rs
@@ -7,6 +7,7 @@ use serenity::model::guild::{Guild, Role, Member};
use serenity::model::id::*;
use serenity::model::misc::Mentionable;
use serenity::prelude::RwLock;
+use serenity::framework::standard::CommandError;
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::Arc;
@@ -158,6 +159,15 @@ pub fn check_rank<T: AsRef<Vec<RoleId>>>(roles: Vec<i64>, member: T) -> bool {
false
}
+pub fn check_mentions(message: &Message) -> bool { // Result<(), CommandError>
+ if message.mentions.len() >= 1 {
+ if message.mentions.len() == 1 {
+ if !message.mentions_user_id(BOT_ID) { return true }
+ } else { return true }
+ }
+ false
+}
+
/// Parses a string for flags preceded by `/`
/// The HashMap returned correlates to `/{key} {value}` where value may be an empty string.
/// Additionally, the map will contain the key "rest" which contains anything in the string prior