mirror of
https://github.com/RPCS3/discord-bot.git
synced 2025-02-27 21:25:30 +00:00
try to scan forwarded message
it will fail (because discord is great at api design), but at least we'll try
This commit is contained in:
parent
f0fffeca7e
commit
e00eee4b60
@ -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))
|
||||
|
@ -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<DiscordMessage?> GetMessageAsync(this DiscordClient client, DiscordChannel channel, ulong messageId)
|
||||
{
|
||||
|
||||
return await channel.GetMessageAsync(messageId).ConfigureAwait(false);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user