Fixed websocket message mention detection
This commit is contained in:
@@ -62,6 +62,9 @@ namespace Discord
|
||||
internal static ImmutableArray<TRole> GetRoleMentions<TRole>(string text, IGuild guild)
|
||||
where TRole : class, IRole
|
||||
{
|
||||
if (guild == null)
|
||||
return ImmutableArray.Create<TRole>();
|
||||
|
||||
var matches = _roleRegex.Matches(text);
|
||||
var builder = ImmutableArray.CreateBuilder<TRole>(matches.Count);
|
||||
foreach (var match in matches.OfType<Match>())
|
||||
|
||||
@@ -96,10 +96,11 @@ namespace Discord.WebSocket
|
||||
if (model.Content.IsSpecified)
|
||||
{
|
||||
var text = model.Content.Value;
|
||||
var guild = (Channel as SocketGuildChannel)?.Guild;
|
||||
|
||||
_mentionedUsers = MentionsHelper.GetUserMentions(text, null, mentions);
|
||||
_mentionedChannelIds = MentionsHelper.GetChannelMentions(text, null);
|
||||
_mentionedRoles = MentionsHelper.GetRoleMentions<RestRole>(text, null);
|
||||
_mentionedUsers = MentionsHelper.GetUserMentions(text, Channel, mentions);
|
||||
_mentionedChannelIds = MentionsHelper.GetChannelMentions(text, guild);
|
||||
_mentionedRoles = MentionsHelper.GetRoleMentions<RestRole>(text, guild);
|
||||
model.Content = text;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user