From 5651cc378e0859f21f21d8cb3838904af13e30ba Mon Sep 17 00:00:00 2001 From: Michal Orlik Date: Sun, 29 Oct 2023 18:32:55 +0100 Subject: [PATCH] chore: add more debug to cooldown --- src/systems/cooldown.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/systems/cooldown.ts b/src/systems/cooldown.ts index e30ea3ce522..a914e782b4b 100644 --- a/src/systems/cooldown.ts +++ b/src/systems/cooldown.ts @@ -315,7 +315,9 @@ class Cooldown extends System { let result = false; const affectedCooldowns: CooldownEntity[] = []; + for (const cooldown of data) { + debug('cooldown.check', `Checking cooldown entity: ${JSON.stringify(cooldown)}`); if (cooldown.type === 'default') { debug('cooldown.check', `Checking default cooldown ${cooldown.name} (${cooldown.permId}) ${cooldown.canBeRunAt}`); if (cooldown.canBeRunAt >= Date.now()) { @@ -339,7 +341,11 @@ class Cooldown extends System { } continue; } + debug('cooldown.check', `isOwner: ${isOwner(opts.sender)} isModerator: ${user.isModerator} isSubscriber: ${user.isSubscriber}`); + debug('cooldown.check', `isOwnerAffected: ${cooldown.isOwnerAffected} isModeratorAffected: ${cooldown.isModeratorAffected} isSubscriberAffected: ${cooldown.isSubscriberAffected}`); + if ((isOwner(opts.sender) && !cooldown.isOwnerAffected) || (user.isModerator && !cooldown.isModeratorAffected) || (user.isSubscriber && !cooldown.isSubscriberAffected)) { + debug('cooldown.check', `User is not affected by this cooldown entity`); result = true; continue; } @@ -392,6 +398,7 @@ class Cooldown extends System { while(cache.length > 50) { cache.shift(); } + debug('cooldown.check', `User ${opts.sender.userName}#${opts.sender.userId} have ${result ? 'no' : 'some'} cooldowns`); return result; } catch (e: any) { error(`Something went wrong during cooldown check: ${e.stack}`);