add monthly as day increment option
ci/woodpecker/push/woodpecker Pipeline was successful Details

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

@ -29,7 +29,6 @@
"discord-api-types": "^0.27.3", "discord-api-types": "^0.27.3",
"discord.js": "^13.6.0", "discord.js": "^13.6.0",
"dotenv": "^16.0.0", "dotenv": "^16.0.0",
"eslint": "^8.2.0",
"express": "^4.17.1", "express": "^4.17.1",
"typescript": "^4.4.4", "typescript": "^4.4.4",
"winston": "^3.3.3" "winston": "^3.3.3"
@ -39,6 +38,7 @@
"@typescript-eslint/eslint-plugin": "^5.3.0", "@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0", "@typescript-eslint/parser": "^5.3.0",
"jest": "^27.3.1", "jest": "^27.3.1",
"eslint": "^8.2.0",
"jest-cli": "^27.3.1", "jest-cli": "^27.3.1",
"nodemon": "^2.0.14", "nodemon": "^2.0.14",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",

View File

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