Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Jun 20, 2024
1 parent 3b4e2a5 commit c6720c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/systems/raffles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,18 @@ class Raffles extends System {
announceNewEntriesCount = 0;
}

async announce () {
async announce (skipLock = false) {
if (!isDbConnected) {
return;
}

if (announceMutex.isLocked()) {
return;
if (!skipLock) {
if (announceMutex.isLocked()) {
return;
}
await announceMutex.acquire();
setTimeout(() => announceMutex.release(), 60000);
}
await announceMutex.acquire();
setTimeout(() => announceMutex.release(), 60000);

const raffle = await AppDataSource.getRepository(Raffle).findOne({ where: { winner: IsNull(), isClosed: false }, relations: ['participants'] });
const isTimeToAnnounce = new Date().getTime() - new Date(this.lastAnnounce).getTime() >= (this.raffleAnnounceInterval * 60 * 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('Permissions - https://community.sogebot.xyz/t/spotify-user-banlist/192
userIds: [],
excludeUserIds: ['7'],
filters: [],
scopes: [],
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Raffles - announce should contain total entries #4175 - @func3', () =>
raffles.lastAnnounceMessageCount = 0;
raffles.lastAnnounce = 0;
raffles.raffleAnnounceMessageInterval = 0;
await raffles.announce();
await raffles.announce(true);
await message.isSentRaw('Raffle is running (150 entries). To enter type "!winme <1-100>". Raffle is opened for everyone.', { userName: '__bot__' })
});
});

0 comments on commit c6720c7

Please sign in to comment.