prevent poll close if event is less than 24h old
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 1m15s

This commit is contained in:
2023-06-17 13:03:48 +02:00
parent 07849d331a
commit 4cc332820f
2 changed files with 10 additions and 2 deletions

View File

@ -164,6 +164,14 @@ export async function checkForPollsToClose(guild: Guild): Promise<void> {
return
}
const createDate: Date = toDate(updatedEvent.createdTimestamp)
const closePollMinDate: Date = addDays(createDate, 1)
if(isAfter(closePollMinDate, Date.now())) {
logger.info("Event is less than 24h old. Not closing poll!", { guildId: guild.id, requestId })
return
}
const eventDate: Date = toDate(updatedEvent.scheduledStartTimestamp)
const closePollDate: Date = addDays(eventDate, -2)