handle dates more explicitly

This commit is contained in:
mightypanders 2022-05-05 21:38:10 +02:00
parent 0c63b20ffe
commit 2f2817897f

View File

@ -18,11 +18,16 @@ export function handleRepeatingEvent(oldguildScheduledEvent: GuildScheduledEvent
if (needsToBeRepeated(repetitionInfo)) { if (needsToBeRepeated(repetitionInfo)) {
try { try {
const newDate = repetitionInfo.schedule.getNewDate(oldguildScheduledEvent.scheduledStartAt)
if (repetitionInfo.endDate && (repetitionInfo.endDate <= newDate)) {
console.log(`Wont repeat: EndDate: ${repetitionInfo.endDate} RepetitionDate: ${newDate}`)
return
}
const newRepetitonString = buildNewRepetitionString(repetitionInfo) const newRepetitonString = buildNewRepetitionString(repetitionInfo)
const newEventOptions: GuildScheduledEventCreateOptions = { const newEventOptions: GuildScheduledEventCreateOptions = {
name: oldguildScheduledEvent.name, name: oldguildScheduledEvent.name,
description: addRepetitonStringToEventDescription(oldguildScheduledEvent.description, newRepetitonString), description: addRepetitonStringToEventDescription(oldguildScheduledEvent.description, newRepetitonString),
scheduledStartTime: repetitionInfo.schedule.getNewDate(oldguildScheduledEvent.scheduledStartAt), scheduledStartTime: newDate,
privacyLevel: oldguildScheduledEvent.privacyLevel, privacyLevel: oldguildScheduledEvent.privacyLevel,
entityType: oldguildScheduledEvent.entityType, entityType: oldguildScheduledEvent.entityType,
channel: oldguildScheduledEvent.channel?.id, channel: oldguildScheduledEvent.channel?.id,