Only add everyone to mentionedroles if the user has permissions

This commit is contained in:
RogueException
2015-11-03 17:29:59 -04:00
parent b3b30256fd
commit 0eb0e14bba
2 changed files with 6 additions and 4 deletions

View File

@@ -52,11 +52,12 @@ namespace Discord
return '#' + e.Value; return '#' + e.Value;
})); }));
} }
internal static string CleanRoleMentions(DiscordClient client, Server server, string text, List<Role> roles = null) internal static string CleanRoleMentions(DiscordClient client, User user, Channel channel, string text, List<Role> roles = null)
{ {
return _roleRegex.Replace(text, new MatchEvaluator(e => return _roleRegex.Replace(text, new MatchEvaluator(e =>
{ {
roles.Add(server.EveryoneRole); if (roles != null && user.GetPermissions(channel).MentionEveryone)
roles.Add(channel.Server.EveryoneRole);
return e.Value; return e.Value;
})); }));
} }

View File

@@ -177,7 +177,8 @@ namespace Discord
internal void Update(MessageInfo model) internal void Update(MessageInfo model)
{ {
var server = Server; var channel = Channel;
var server = channel.Server;
if (model.Attachments != null) if (model.Attachments != null)
{ {
Attachments = model.Attachments Attachments = model.Attachments
@@ -226,7 +227,7 @@ namespace Discord
if (server != null) if (server != null)
{ {
text = Mention.CleanChannelMentions(_client, server, text, mentionedChannels); text = Mention.CleanChannelMentions(_client, server, text, mentionedChannels);
text = Mention.CleanRoleMentions(_client, server, text, mentionedRoles); text = Mention.CleanRoleMentions(_client, User, channel, text, mentionedRoles);
} }
Text = text; Text = text;