2022-04-13 21:38:59 +02:00
|
|
|
import { GuildScheduledEvent } from "discord.js"
|
2022-04-23 21:32:32 +02:00
|
|
|
import { config } from "../configuration"
|
|
|
|
import { repetitionMarkerIsFound, validateRepetitionStringAndSendMessageOnFail } from "../handler/repeatingEvents/helper"
|
2022-04-13 21:38:59 +02:00
|
|
|
import { handleRepeatingEvent } from "../handler/repeatingEvents/repeatingEvents.controller"
|
|
|
|
|
|
|
|
|
2022-03-05 01:24:05 +01:00
|
|
|
export const name = 'guildScheduledEventUpdate'
|
2022-04-12 22:39:47 +02:00
|
|
|
export function execute(oldguildScheduledEvent: GuildScheduledEvent, newguildScheduledEvent: GuildScheduledEvent) {
|
2022-04-23 21:32:32 +02:00
|
|
|
if (config.debug) {
|
|
|
|
console.dir(oldguildScheduledEvent)
|
|
|
|
console.dir(newguildScheduledEvent)
|
|
|
|
}
|
2022-04-12 22:39:47 +02:00
|
|
|
|
2022-04-23 21:32:32 +02:00
|
|
|
if (oldguildScheduledEvent.description !== newguildScheduledEvent.description) {
|
|
|
|
validateRepetitionStringAndSendMessageOnFail(newguildScheduledEvent)
|
|
|
|
}
|
2022-04-13 21:38:59 +02:00
|
|
|
if (oldguildScheduledEvent.description && repetitionMarkerIsFound(oldguildScheduledEvent.description)) {
|
2022-04-12 22:39:47 +02:00
|
|
|
// valid repeating event
|
2022-04-13 21:38:59 +02:00
|
|
|
if (newguildScheduledEvent.status === 'COMPLETED')
|
|
|
|
handleRepeatingEvent(oldguildScheduledEvent, newguildScheduledEvent)
|
2022-04-12 22:39:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|