Fixed websocket message mention detection

This commit is contained in:
RogueException
2016-10-04 13:37:40 -03:00
parent 857255abde
commit c67bd04c5a
2 changed files with 7 additions and 3 deletions

View File

@@ -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>())

View File

@@ -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;
}
}