diff --git a/src/client/components/observers/GuildLogging.ts b/src/client/components/observers/GuildLogging.ts index a8a390b..1ad3ba0 100644 --- a/src/client/components/observers/GuildLogging.ts +++ b/src/client/components/observers/GuildLogging.ts @@ -39,6 +39,11 @@ const CONSTANTS: { WEEK: 7 * 24 * 60 * 60 }; +const debounce: { + joins: { [key: string]: number }, + leaves: { [key: string]: number }, +} = { joins: {}, leaves: {} }; + class GuildLogger extends Observer { #attachmentWebhook: WebhookClient; @@ -858,6 +863,11 @@ class GuildLogger extends Observer if (!setting.channel || !setting.enabled || !setting.join) return; + if (!debounce.joins[member.id] || debounce.joins[member.id] < (Date.now() - 60_000)) + debounce.joins[member.id] = Date.now(); + else + return; + const logChannel = await wrapper.resolveChannel(setting.channel); if (!logChannel) return; @@ -879,6 +889,11 @@ class GuildLogger extends Observer if (!setting.channel || !setting.enabled || !setting.leave) return; + if (!debounce.leaves[member.id] || debounce.leaves[member.id] < (Date.now() - 60_000)) + debounce.leaves[member.id] = Date.now(); + else + return; + const logChannel = await wrapper.resolveChannel(setting.channel); if (!logChannel) return;