From 75821120790d81e0e7b5bca1f11374d7cb7f2af5 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Wed, 24 Jan 2024 01:12:46 +0100 Subject: [PATCH] fix: GetMentions NRE Signed-off-by: Lala Sabathil --- .../Entities/Message/DiscordMessage.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/DisCatSharp/Entities/Message/DiscordMessage.cs b/DisCatSharp/Entities/Message/DiscordMessage.cs index 3f776302eb..9a3f6e9bf8 100644 --- a/DisCatSharp/Entities/Message/DiscordMessage.cs +++ b/DisCatSharp/Entities/Message/DiscordMessage.cs @@ -478,15 +478,20 @@ private List GetMentions() { var mentions = new List(); - if (this.ReferencedMessage != null && this.MentionedUsersInternal.Contains(this.ReferencedMessage.Author)) - mentions.Add(new RepliedUserMention()); + try + { + if (this.ReferencedMessage is not null && this.MentionedUsersInternal && this.MentionedUsersInternal.Contains(this.ReferencedMessage.Author)) + mentions.Add(new RepliedUserMention()); - if (this.MentionedUsersInternal.Count != 0) - mentions.AddRange(this.MentionedUsersInternal.Select(m => (IMention)new UserMention(m))); - - if (this.MentionedRoleIds.Count != 0) - mentions.AddRange(this.MentionedRoleIds.Select(r => (IMention)new RoleMention(r))); + if (this.MentionedUsersInternal.Count != 0) + mentions.AddRange(this.MentionedUsersInternal.Select(m => (IMention)new UserMention(m))); + if (this.MentionedRoleIds.Count != 0) + mentions.AddRange(this.MentionedRoleIds.Select(r => (IMention)new RoleMention(r))); + } + catch + { } + return mentions; }