Check if less than 2 days between create and start for deciding if to close
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 1m9s
All checks were successful
Build a docker image for node-jellyfin-role-bot / build-docker-image (push) Successful in 1m9s
This commit is contained in:
parent
4cc332820f
commit
670a64af22
@ -1,4 +1,4 @@
|
||||
import { addDays, format, isAfter, toDate } from 'date-fns'
|
||||
import { addDays, differenceInDays, format, isAfter, toDate } from 'date-fns'
|
||||
import { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, TextChannel } from 'discord.js'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import { client } from '../..'
|
||||
@ -165,14 +165,14 @@ export async function checkForPollsToClose(guild: Guild): Promise<void> {
|
||||
}
|
||||
|
||||
const createDate: Date = toDate(updatedEvent.createdTimestamp)
|
||||
const closePollMinDate: Date = addDays(createDate, 1)
|
||||
const eventDate: Date = toDate(updatedEvent.scheduledStartTimestamp)
|
||||
const difference: number = differenceInDays(createDate, eventDate)
|
||||
|
||||
if(isAfter(closePollMinDate, Date.now())) {
|
||||
logger.info("Event is less than 24h old. Not closing poll!", { guildId: guild.id, requestId })
|
||||
if (difference <= 2) {
|
||||
logger.info("Less than two days between event create and event start. Not closing poll.", { guildId: guild.id, requestId })
|
||||
return
|
||||
}
|
||||
|
||||
const eventDate: Date = toDate(updatedEvent.scheduledStartTimestamp)
|
||||
const closePollDate: Date = addDays(eventDate, -2)
|
||||
|
||||
if (isAfter(Date.now(), closePollDate)) {
|
||||
|
Loading…
Reference in New Issue
Block a user