node-event-bot/server/events/guildScheduledEventUpdate.ts

24 lines
993 B
TypeScript
Raw Normal View History

import { GuildScheduledEvent } from "discord.js"
import { config } from "../configuration"
import { repetitionMarkerIsFound, validateRepetitionStringAndSendMessageOnFail } from "../handler/repeatingEvents/helper"
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) {
if (config.debug) {
console.dir(oldguildScheduledEvent)
console.dir(newguildScheduledEvent)
}
2022-04-12 22:39:47 +02:00
if (oldguildScheduledEvent.description !== newguildScheduledEvent.description) {
validateRepetitionStringAndSendMessageOnFail(newguildScheduledEvent)
}
if (oldguildScheduledEvent.description && repetitionMarkerIsFound(oldguildScheduledEvent.description)) {
2022-04-12 22:39:47 +02:00
// valid repeating event
if (newguildScheduledEvent.status === 'COMPLETED')
handleRepeatingEvent(oldguildScheduledEvent, newguildScheduledEvent)
2022-04-12 22:39:47 +02:00
}
}