node-event-bot/server/events/guildScheduledEventUpdate.ts
mightypanders 180c467826
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
refactoring and adding capability to recognize more schedules
2022-04-13 21:38:59 +02:00

19 lines
729 B
TypeScript

import { GuildScheduledEvent } from "discord.js"
import { handleRepeatingEvent } from "../handler/repeatingEvents/repeatingEvents.controller"
const repetitionMarkerIsFound = (desc: string): boolean => desc.includes('$rep')
export const name = 'guildScheduledEventUpdate'
export function execute(oldguildScheduledEvent: GuildScheduledEvent, newguildScheduledEvent: GuildScheduledEvent) {
console.dir(oldguildScheduledEvent)
console.dir(newguildScheduledEvent)
if (oldguildScheduledEvent.description && repetitionMarkerIsFound(oldguildScheduledEvent.description)) {
// valid repeating event
if (newguildScheduledEvent.status === 'COMPLETED')
handleRepeatingEvent(oldguildScheduledEvent, newguildScheduledEvent)
}
}