Only add everyone to mentionedroles if the user has permissions
This commit is contained in:
@@ -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;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user