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,9 +1,11 @@
import { GuildScheduledEvent } from 'discord.js' import { GuildScheduledEvent } from 'discord.js'
import { validateRepetitionStringAndSendMessageOnFail } from '../handler/repeatingEvents/helper'
export const name = 'guildScheduledEventCreate' export const name = 'guildScheduledEventCreate'
export function execute(guildScheduledEvent: GuildScheduledEvent) { export async function execute(guildScheduledEvent: GuildScheduledEvent) {
try{ try {
console.log(`${JSON.stringify(guildScheduledEvent)} has been created.`) console.log(`${JSON.stringify(guildScheduledEvent)} has been created.`)
}catch(error) { validateRepetitionStringAndSendMessageOnFail(guildScheduledEvent)
} catch (error) {
console.error(error) console.error(error)
} }
} }

View File

@ -1,13 +1,19 @@
import { GuildScheduledEvent } from "discord.js" 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" import { handleRepeatingEvent } from "../handler/repeatingEvents/repeatingEvents.controller"
export const name = 'guildScheduledEventUpdate' export const name = 'guildScheduledEventUpdate'
export function execute(oldguildScheduledEvent: GuildScheduledEvent, newguildScheduledEvent: GuildScheduledEvent) { export function execute(oldguildScheduledEvent: GuildScheduledEvent, newguildScheduledEvent: GuildScheduledEvent) {
if (config.debug) {
console.dir(oldguildScheduledEvent) console.dir(oldguildScheduledEvent)
console.dir(newguildScheduledEvent) console.dir(newguildScheduledEvent)
}
if (oldguildScheduledEvent.description !== newguildScheduledEvent.description) {
validateRepetitionStringAndSendMessageOnFail(newguildScheduledEvent)
}
if (oldguildScheduledEvent.description && repetitionMarkerIsFound(oldguildScheduledEvent.description)) { if (oldguildScheduledEvent.description && repetitionMarkerIsFound(oldguildScheduledEvent.description)) {
// valid repeating event // valid repeating event
if (newguildScheduledEvent.status === 'COMPLETED') if (newguildScheduledEvent.status === 'COMPLETED')