Don't send update events for messages not logged
This commit is contained in:
parent
ddfc2fc612
commit
a6c6ba9550
2 changed files with 4 additions and 2 deletions
|
@ -13,6 +13,7 @@ internal partial class ModLogs {
|
|||
private async Task HandleDelete(Cacheable<IMessage, ulong> argMsg, Cacheable<IMessageChannel, ulong> argChannel) {
|
||||
const int MaxPreviewLength = 750;
|
||||
if (argChannel.Value is not SocketTextChannel channel) return;
|
||||
|
||||
var conf = GetGuildState<ModuleConfig>(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<ModuleConfig>(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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue