diff --git a/CompatBot/Database/Providers/ContentFilter.cs b/CompatBot/Database/Providers/ContentFilter.cs index 0fca2d3e..ab652931 100644 --- a/CompatBot/Database/Providers/ContentFilter.cs +++ b/CompatBot/Database/Providers/ContentFilter.cs @@ -13,6 +13,7 @@ using DSharpPlus.Entities; using Microsoft.EntityFrameworkCore; using NReco.Text; using Microsoft.Extensions.Caching.Memory; +using NLog; namespace CompatBot.Database.Providers; @@ -134,7 +135,21 @@ internal static class ContentFilter return true; } #endif - + + if (message.Reference is {} refMsg) + { + try + { + var msg = await client.GetMessageAsync(refMsg.Channel, refMsg.Message.Id).ConfigureAwait(false); + if (msg is not null) + message = msg; + } + catch (Exception e) + { + Config.Log.Warn(e, "Failed to get message reference content"); + } + } + var content = new StringBuilder(message.Content).AppendLine(); if (message.Attachments is not null) foreach (var attachment in message.Attachments.Where(a => a is not null)) diff --git a/CompatBot/Utils/Extensions/CommandContextExtensions.cs b/CompatBot/Utils/Extensions/CommandContextExtensions.cs index 8955bf1c..50e288d6 100644 --- a/CompatBot/Utils/Extensions/CommandContextExtensions.cs +++ b/CompatBot/Utils/Extensions/CommandContextExtensions.cs @@ -2,6 +2,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using CompatBot.Commands.Attributes; +using DSharpPlus; using DSharpPlus.CommandsNext; using DSharpPlus.CommandsNext.Converters; using DSharpPlus.Entities; @@ -50,4 +51,10 @@ public static partial class CommandContextExtensions return channel.GetMessageAsync(msgId); return Task.FromResult((DiscordMessage?)null); } + + public static async Task GetMessageAsync(this DiscordClient client, DiscordChannel channel, ulong messageId) + { + + return await channel.GetMessageAsync(messageId).ConfigureAwait(false); + } } \ No newline at end of file