From a6c6ba955036a70799fe7b215fa31c2afe9bbefb Mon Sep 17 00:00:00 2001 From: Noi Date: Mon, 17 Jul 2023 10:46:41 -0700 Subject: [PATCH] Don't send update events for messages not logged --- Modules/ModLogs/ModLogs_Messages.cs | 3 ++- Services/EntityCache/MessageCachingSubservice.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/ModLogs/ModLogs_Messages.cs b/Modules/ModLogs/ModLogs_Messages.cs index 78f9d1d..7f1714b 100644 --- a/Modules/ModLogs/ModLogs_Messages.cs +++ b/Modules/ModLogs/ModLogs_Messages.cs @@ -13,6 +13,7 @@ internal partial class ModLogs { private async Task HandleDelete(Cacheable argMsg, Cacheable argChannel) { const int MaxPreviewLength = 750; if (argChannel.Value is not SocketTextChannel channel) return; + var conf = GetGuildState(channel.Guild.Id); if ((conf?.LogMessageDeletions ?? false) == false) return; var reportChannel = conf?.ReportingChannel?.FindChannelIn(channel.Guild, true); @@ -71,13 +72,13 @@ internal partial class ModLogs { var channel = (SocketTextChannel)newMsg.Channel; var conf = GetGuildState(channel.Guild.Id); + if (newMsg.Author.IsBot || newMsg.Author.IsWebhook) return; var reportChannel = conf?.ReportingChannel?.FindChannelIn(channel.Guild, true); if (reportChannel == null) return; if (reportChannel.Id == channel.Id) { Log(channel.Guild, "Message edited in the reporting channel. Suppressing report."); return; } - if (newMsg.Author.IsBot) return; // Do not report bot edits var reportEmbed = new EmbedBuilder() .WithColor(new Color(0xffff00)) // yellow diff --git a/Services/EntityCache/MessageCachingSubservice.cs b/Services/EntityCache/MessageCachingSubservice.cs index 8346da6..5c54f1a 100644 --- a/Services/EntityCache/MessageCachingSubservice.cs +++ b/Services/EntityCache/MessageCachingSubservice.cs @@ -17,13 +17,14 @@ class MessageCachingSubservice { // This event is fired also when a link preview embed is added to a message. In those situations, the message's edited timestamp // remains null, in addition to having other unusual and unexpected properties. We are not interested in these. if (!arg2.EditedTimestamp.HasValue) return Task.CompletedTask; + if (arg2.Author.IsBot || arg2.Author.IsWebhook) return Task.CompletedTask; // we don't log these anyway, so don't pass them on return AddOrUpdateCacheItemAsync(arg2, true); } private async Task AddOrUpdateCacheItemAsync(SocketMessage arg, bool isUpdate) { //if (!Common.Utilities.IsValidUserMessage(arg, out _)) return; if (arg.Channel is not SocketTextChannel) return; - if (arg.Author.IsWebhook) return; // do get bot messages, don't get webhooks + if (arg.Author.IsBot || arg.Author.IsWebhook) return; // do not get messages from an automated source if (((IMessage)arg).Type != MessageType.Default) return; if (arg is SocketSystemMessage) return;