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