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

19 lines
729 B
TypeScript
Raw Normal View History

import { GuildScheduledEvent } from "discord.js"
import { handleRepeatingEvent } from "../handler/repeatingEvents/repeatingEvents.controller"
const repetitionMarkerIsFound = (desc: string): boolean => desc.includes('$rep')
2022-04-12 22:39:47 +02:00
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) {
console.dir(oldguildScheduledEvent)
console.dir(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
}
}