24 lines
993 B
TypeScript
24 lines
993 B
TypeScript
import { GuildScheduledEvent } from "discord.js"
|
|
import { config } from "../configuration"
|
|
import { repetitionMarkerIsFound, validateRepetitionStringAndSendMessageOnFail } from "../handler/repeatingEvents/helper"
|
|
import { handleRepeatingEvent } from "../handler/repeatingEvents/repeatingEvents.controller"
|
|
|
|
|
|
export const name = 'guildScheduledEventUpdate'
|
|
export function execute(oldguildScheduledEvent: GuildScheduledEvent, newguildScheduledEvent: GuildScheduledEvent) {
|
|
if (config.debug) {
|
|
console.dir(oldguildScheduledEvent)
|
|
console.dir(newguildScheduledEvent)
|
|
}
|
|
|
|
if (oldguildScheduledEvent.description !== newguildScheduledEvent.description) {
|
|
validateRepetitionStringAndSendMessageOnFail(newguildScheduledEvent)
|
|
}
|
|
if (oldguildScheduledEvent.description && repetitionMarkerIsFound(oldguildScheduledEvent.description)) {
|
|
// valid repeating event
|
|
if (newguildScheduledEvent.status === 'COMPLETED')
|
|
handleRepeatingEvent(oldguildScheduledEvent, newguildScheduledEvent)
|
|
}
|
|
}
|
|
|