16 lines
586 B
TypeScript
16 lines
586 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}`
|
||
|
}
|