forked from Galactic/galactic-bot
join/leave log debounce
This commit is contained in:
parent
775a459dee
commit
faed102ebb
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user