send dm on failure to parse
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				ci/woodpecker/push/woodpecker Pipeline was successful
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	ci/woodpecker/push/woodpecker Pipeline was successful
				
			This commit is contained in:
		@@ -1,7 +1,6 @@
 | 
			
		||||
import { format } from "date-fns"
 | 
			
		||||
import add from "date-fns/add"
 | 
			
		||||
import { DateResolvable, Guild, GuildScheduledEvent, GuildScheduledEventCreateOptions } from "discord.js"
 | 
			
		||||
import { client } from "../../.."
 | 
			
		||||
import { Guild, GuildScheduledEvent, GuildScheduledEventCreateOptions } from "discord.js"
 | 
			
		||||
import { sendFailureDM } from "../../helper/sendFailureDM"
 | 
			
		||||
import { CustomError, errorCodes, Maybe } from "../../interfaces"
 | 
			
		||||
import { RepetitonInfo, Schedule, supportedSchedule } from "../../types/scheduledEventTypes"
 | 
			
		||||
 | 
			
		||||
@@ -49,8 +48,8 @@ export function determineRepetitionCount(description: string): { totalAmount: nu
 | 
			
		||||
 | 
			
		||||
export function buildNewRepetitionString(repetitionInfo: RepetitonInfo) {
 | 
			
		||||
	if (repetitionInfo.endDate)
 | 
			
		||||
		return `$rep:${repetitionInfo.schedule}:${format(repetitionInfo.endDate, 'yyyy-MM-dd')}`
 | 
			
		||||
	return `$rep:${repetitionInfo.schedule}:${repetitionInfo.alreadyOccured + 1}/${repetitionInfo.totalAmount}`
 | 
			
		||||
		return `$rep:${repetitionInfo.schedule.getSanitizedScheduleString()}:${format(repetitionInfo.endDate, 'yyyy-MM-dd')}`
 | 
			
		||||
	return `$rep:${repetitionInfo.schedule.getSanitizedScheduleString()}:${repetitionInfo.alreadyOccured + 1}/${repetitionInfo.totalAmount}`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function addRepetitonStringToEventDescription(oldguildScheduledEvent: string, newRepetitonString: string): string | undefined {
 | 
			
		||||
@@ -104,6 +103,7 @@ export function checkIfRepetitionStringIsValid(description: string): string {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function validateRepetitionStringAndSendMessageOnFail(event: GuildScheduledEvent): Promise<void> {
 | 
			
		||||
	console.log('This should not be accessed')
 | 
			
		||||
 | 
			
		||||
	const validResponses = [
 | 
			
		||||
		'valid',
 | 
			
		||||
@@ -114,13 +114,6 @@ export async function validateRepetitionStringAndSendMessageOnFail(event: GuildS
 | 
			
		||||
		// do success things?
 | 
			
		||||
	} else {
 | 
			
		||||
		const creatorMessage = `The repetition string in your event could not be parsed. Reason: ${resultstring}`
 | 
			
		||||
		console.log(creatorMessage)
 | 
			
		||||
		if (!event.creatorId) throw new CustomError('No creator ID present', errorCodes.no_creator_id)
 | 
			
		||||
		const creator = await client.users.fetch(event.creatorId)
 | 
			
		||||
		console.log(`Creator ${JSON.stringify(creator)}`)
 | 
			
		||||
		if (creator)
 | 
			
		||||
			if (!creator.dmChannel)
 | 
			
		||||
				await creator.createDM()
 | 
			
		||||
		await creator.dmChannel?.send(creatorMessage)
 | 
			
		||||
		sendFailureDM(creatorMessage, event.creatorId ?? undefined)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user