Skip to content

Commit

Permalink
chore: add more debug to cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Oct 29, 2023
1 parent 81b6a41 commit 5651cc3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/systems/cooldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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}`);
Expand Down

0 comments on commit 5651cc3

Please sign in to comment.