join/leave log debounce

This commit is contained in:
Erik 2024-01-25 16:27:21 +02:00
parent 775a459dee
commit faed102ebb

View File

@ -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<TextChannel>(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<TextChannel>(setting.channel);
if (!logChannel)
return;