jellyfin-discord-bot/server/helper/sendFailureDM.ts
2023-10-21 14:56:15 +02:00

14 lines
578 B
TypeScript

import { CustomError, errorCodes } from "../interfaces"
import { logger } from "../logger"
import { ExtendedClient } from "../structures/client"
export async function sendFailureDM(creatorMessage: string, client: ExtendedClient, creatorId?: string): Promise<void> {
if (!creatorId) throw new CustomError('No creator ID present', errorCodes.no_creator_id)
const creator = await client.users.fetch(creatorId)
logger.info(`Creator ${JSON.stringify(creator)}`)
if (creator)
if (!creator.dmChannel)
await creator.createDM()
await creator.dmChannel?.send(creatorMessage)
}