node-event-bot/server/events/guildScheduledEventUpdate.ts
mightypanders 790a0d65f4
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
use repetitionstring validator in new and updated events
2022-04-23 21:32:32 +02:00

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)
}
}