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 { Guild, GuildScheduledEvent, GuildScheduledEventEditOptions, GuildScheduledEventSetStatusArg, GuildScheduledEventStatus, Message, MessageCreateOptions, TextChannel } from 'discord.js'
|
||||||
import { v4 as uuid } from 'uuid'
|
import { v4 as uuid } from 'uuid'
|
||||||
import { client } from '../..'
|
import { client } from '../..'
|
||||||
@ -165,14 +165,14 @@ export async function checkForPollsToClose(guild: Guild): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createDate: Date = toDate(updatedEvent.createdTimestamp)
|
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())) {
|
if (difference <= 2) {
|
||||||
logger.info("Event is less than 24h old. Not closing poll!", { guildId: guild.id, requestId })
|
logger.info("Less than two days between event create and event start. Not closing poll.", { guildId: guild.id, requestId })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventDate: Date = toDate(updatedEvent.scheduledStartTimestamp)
|
|
||||||
const closePollDate: Date = addDays(eventDate, -2)
|
const closePollDate: Date = addDays(eventDate, -2)
|
||||||
|
|
||||||
if (isAfter(Date.now(), closePollDate)) {
|
if (isAfter(Date.now(), closePollDate)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user