use repetitionstring validator in new and updated events
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
mightypanders 2022-04-23 21:32:32 +02:00
parent b22cb1167d
commit 790a0d65f4
2 changed files with 15 additions and 7 deletions

View File

@ -1,8 +1,10 @@
import { GuildScheduledEvent } from 'discord.js'
import { validateRepetitionStringAndSendMessageOnFail } from '../handler/repeatingEvents/helper'
export const name = 'guildScheduledEventCreate'
export function execute(guildScheduledEvent: GuildScheduledEvent) {
export async function execute(guildScheduledEvent: GuildScheduledEvent) {
try {
console.log(`${JSON.stringify(guildScheduledEvent)} has been created.`)
validateRepetitionStringAndSendMessageOnFail(guildScheduledEvent)
} catch (error) {
console.error(error)
}

View File

@ -1,13 +1,19 @@
import { GuildScheduledEvent } from "discord.js"
import { repetitionMarkerIsFound } from "../handler/repeatingEvents/helper"
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')