diff options
| author | Fuwn <[email protected]> | 2020-11-04 20:42:40 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2020-11-04 20:42:40 -0800 |
| commit | ed4bf9cb63576c89cad9179d9de3e0e2dd67a8ea (patch) | |
| tree | 9883d6cfbe7f9f0e5708e0b0cfc3b9fcac096549 /src/modules | |
| parent | fix: parse for mentions not just @everyone (diff) | |
| download | dep-core-next-ed4bf9cb63576c89cad9179d9de3e0e2dd67a8ea.tar.xz dep-core-next-ed4bf9cb63576c89cad9179d9de3e0e2dd67a8ea.zip | |
fix: mention handling where it should be handled
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/commands/admins/config.rs | 18 | ||||
| -rw-r--r-- | src/modules/commands/general/fun.rs | 26 |
2 files changed, 23 insertions, 21 deletions
diff --git a/src/modules/commands/admins/config.rs b/src/modules/commands/admins/config.rs index eedd087..c3a0252 100644 --- a/src/modules/commands/admins/config.rs +++ b/src/modules/commands/admins/config.rs @@ -80,9 +80,9 @@ impl Command for ConfigPrefix { } fn execute(&self, _: &mut Context, message: &Message, mut args: Args) -> Result<(), CommandError> { - if !message.mentions.is_empty() { - message.channel_id.say("Sorry, but the prefix can't mention people.")?; - return Ok(()); + if check_mentions(message) { + message.channel_id.say(MENTION_FAIL)?; + return Ok(()) } if let Some(guild_id) = message.guild_id { @@ -91,10 +91,10 @@ impl Command for ConfigPrefix { guild_data.prefix = pre; match db.update_guild(guild_id.0 as i64, guild_data) { Ok(guild) => { - message.channel_id.say(format!("Set prefix to {}", guild.prefix))?; + message.channel_id.say(format!("Set guild prefix to `{}`.", guild.prefix))?; }, Err(_) => { - message.channel_id.say("Failed to change prefix")?; + message.channel_id.say("Unexpected error while changing prefix.")?; }, } } else { @@ -249,7 +249,7 @@ impl Command for ConfigMod { fn options(&self) -> Arc<CommandOptions> { let default = CommandOptions::default(); let options = CommandOptions { - desc: Some("Welcome to moderation!".to_string()), + desc: Some("Configure the moderation log, superstitious much.".to_string()), usage: Some("<add|remove> <role_resolvable>".to_string()), example: Some("add staff".to_string()), min_args: Some(2), @@ -459,9 +459,9 @@ impl Command for ConfigWelcome { } fn execute(&self, _: &mut Context, message: &Message, mut args: Args) -> Result<(), CommandError> { - if !message.mentions.is_empty() { - message.channel_id.say("Try again, my welcome greeting can't be initialized when it mentions someone!.")?; - return Ok(()); + if check_mentions(message) { + message.channel_id.say(MENTION_FAIL)?; + return Ok(()) } if let Some(guild_id) = message.guild_id { diff --git a/src/modules/commands/general/fun.rs b/src/modules/commands/general/fun.rs index 31deeeb..eb3c1e1 100644 --- a/src/modules/commands/general/fun.rs +++ b/src/modules/commands/general/fun.rs @@ -12,6 +12,7 @@ use serenity::framework::standard::{ use serenity::model::channel::Message; use serenity::prelude::Context; use std::sync::Arc; +use crate::core::utils::check_mentions; lazy_static! { static ref DICE_MATCH: Regex = Regex::new(r"(?P<count>\d+)d?(?P<sides>\d*)").expect("Failed to create Regex"); @@ -29,9 +30,9 @@ impl Command for Clapify { } fn execute(&self, _: &mut Context, message: &Message, args: Args) -> Result<(), CommandError> { - if !message.mentions.is_empty() { - message.channel_id.say("Sorry, but I can only clapify non-human things!")?; - return Ok(()); + if check_mentions(message) { + message.channel_id.say(MENTION_FAIL)?; + return Ok(()) } let to_say = args; @@ -190,10 +191,11 @@ impl Command for Opinion { } fn execute(&self, _ctx: &mut Context, message: &Message, args: Args) -> Result<(), CommandError> { - if message.mentions.len() > 1 { - message.channel_id.say("I can't give my opinion on everyone all at once!")?; - return Ok(()); + if check_mentions(message) { + message.channel_id.say(MENTION_FAIL)?; + return Ok(()) } + let random = thread_rng().gen_bool(5.4); // TODO: Make this an embed eventually. if random { @@ -222,9 +224,9 @@ impl Command for Rate { } fn execute(&self, _ctx: &mut Context, message: &Message, args: Args) -> Result<(), CommandError> { - if message.mentions.len() > 1 { - message.channel_id.say("I can't rate everyone at once!")?; - return Ok(()); + if check_mentions(message) { + message.channel_id.say(MENTION_FAIL)?; + return Ok(()) } let random = thread_rng().gen_range(1, 10); @@ -273,9 +275,9 @@ impl Command for Uwufy { } fn execute(&self, _: &mut Context, message: &Message, args: Args) -> Result<(), CommandError> { - if !message.mentions.is_empty() { - message.channel_id.say("Try again, but next time, don't tag anyone please.")?; - return Ok(()); + if check_mentions(message) { + message.channel_id.say(MENTION_FAIL)?; + return Ok(()) } let to_say = args; |