add monthly as day increment option
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
mightypanders
2022-04-13 21:52:32 +02:00
parent d79abb3d93
commit 72b88b8387
2 changed files with 7 additions and 2 deletions

View File

@ -50,6 +50,7 @@ export function addRepetitonStringToEventDescription(oldguildScheduledEvent: str
export function getNewScheduledStart(oldguildScheduledEvent: GuildScheduledEvent<"SCHEDULED" | "ACTIVE" | "COMPLETED" | "CANCELED">, rInfo: RepetitonInfo): DateResolvable {
const oldDate = oldguildScheduledEvent.scheduledStartAt
let daysToAdd = 0
let monthsToAdd = 0
switch (rInfo.schedule) {
case 'daily':
daysToAdd = 1
@ -57,11 +58,15 @@ export function getNewScheduledStart(oldguildScheduledEvent: GuildScheduledEvent
case 'weekly':
daysToAdd = 7
break
case 'monthly':
monthsToAdd = 1
break
default:
throw new Error('No schedule found, cant add days')
}
const duration: Duration = {
days: daysToAdd
days: daysToAdd,
months: monthsToAdd
}
const newDate = add(oldDate, duration)
return newDate