jellyfin-discord-bot/server/helper/dateHelper.ts
Sammy 3a5ea5d4ff
All checks were successful
Compile the repository / compile (pull_request) Successful in 4m8s
improve message clarity when no start date in event found
2023-06-23 19:30:17 +02:00

16 lines
588 B
TypeScript

import { format } from "date-fns";
import { GuildScheduledEvent } from "discord.js";
import { logger } from "../logger";
export function createDateStringFromEvent(event: GuildScheduledEvent, requestId: string, guildId?: string): string {
if(!event.scheduledStartAt) {
logger.error("Event has no start. Cannot create dateString.", {guildId, requestId})
return `"habe keinen Startzeitpunkt ermitteln können"`
}
const date = format(event.scheduledStartAt, "dd.MM")
const time = format(event.scheduledStartAt, "HH:mm")
return `am ${date} um ${time}`
}