Skip to content

Commit 54d082c

Browse files
committed
message logging: ignore if not in home server
1 parent 184b4d1 commit 54d082c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Events/MessageEvent.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public static async Task MessageUpdated(DiscordClient client, MessageUpdatedEven
5151
{
5252
client.Logger.LogDebug("Got a message update event for {message} by {user}", DiscordHelpers.MessageLink(e.Message), e.Message.Author.Id);
5353
}
54+
55+
if (e.Message.Channel.GuildId != Program.cfgjson.ServerID)
56+
return;
57+
5458
await MessageHandlerAsync(client, e.Message, e.Channel, true);
5559
}
5660

@@ -69,7 +73,10 @@ public static async Task MessageDeleted(DiscordClient client, MessageDeletedEven
6973
{
7074
client.Logger.LogDebug("Got a message delete event for {message} by {user}", DiscordHelpers.MessageLink(e.Message), e.Message.Author.Id);
7175
}
72-
76+
77+
if (e.Message.Channel.GuildId != Program.cfgjson.ServerID)
78+
return;
79+
7380
foreach (var warning in await Program.redis.HashGetAllAsync("automaticWarnings"))
7481
{
7582
if (JsonConvert.DeserializeObject<UserWarning>(warning.Value).ContextMessageReference.MessageId == e.Message.Id)
@@ -116,6 +123,9 @@ public static async Task MessagesBulkDeleted(DiscordClient client, MessagesBulkD
116123
}
117124
}
118125

126+
if (e.Messages[0].Channel.GuildId != Program.cfgjson.ServerID)
127+
return;
128+
119129
if (Program.cfgjson.EnablePersistentDb)
120130
{
121131
// log the bulk deleted messages
@@ -268,9 +278,9 @@ public static async Task MessageHandlerAsync(DiscordClient client, DiscordMessag
268278
public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMessage message, DiscordChannel channel, bool isAnEdit = false, bool limitFilters = false, bool wasAutoModBlock = false)
269279
{
270280
#region message logging fill to db
271-
272281
// If db support is enabled, and this message is not in an excluded channel, cache it
273-
if (Program.cfgjson.EnablePersistentDb
282+
if (message.Channel.GuildId == Program.cfgjson.ServerID
283+
&& Program.cfgjson.EnablePersistentDb
274284
&& !Program.cfgjson.MessageLogExcludedChannels.Contains(message.ChannelId)
275285
&& (message.Channel.ParentId is null || !Program.cfgjson.MessageLogExcludedChannels.Contains((ulong)message.Channel.ParentId)))
276286
{

0 commit comments

Comments
 (0)