join/leave log debounce
This commit is contained in:
parent
775a459dee
commit
faed102ebb
@ -39,6 +39,11 @@ const CONSTANTS: {
|
|||||||
WEEK: 7 * 24 * 60 * 60
|
WEEK: 7 * 24 * 60 * 60
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const debounce: {
|
||||||
|
joins: { [key: string]: number },
|
||||||
|
leaves: { [key: string]: number },
|
||||||
|
} = { joins: {}, leaves: {} };
|
||||||
|
|
||||||
class GuildLogger extends Observer
|
class GuildLogger extends Observer
|
||||||
{
|
{
|
||||||
#attachmentWebhook: WebhookClient;
|
#attachmentWebhook: WebhookClient;
|
||||||
@ -858,6 +863,11 @@ class GuildLogger extends Observer
|
|||||||
if (!setting.channel || !setting.enabled || !setting.join)
|
if (!setting.channel || !setting.enabled || !setting.join)
|
||||||
return;
|
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);
|
const logChannel = await wrapper.resolveChannel<TextChannel>(setting.channel);
|
||||||
if (!logChannel)
|
if (!logChannel)
|
||||||
return;
|
return;
|
||||||
@ -879,6 +889,11 @@ class GuildLogger extends Observer
|
|||||||
if (!setting.channel || !setting.enabled || !setting.leave)
|
if (!setting.channel || !setting.enabled || !setting.leave)
|
||||||
return;
|
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);
|
const logChannel = await wrapper.resolveChannel<TextChannel>(setting.channel);
|
||||||
if (!logChannel)
|
if (!logChannel)
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user