jellyfin-discord-bot/server/helper/sendFailureDM.ts

14 lines
578 B
TypeScript
Raw Permalink Normal View History

2023-04-15 22:06:35 +02:00
import { CustomError, errorCodes } from "../interfaces"
2023-10-21 14:56:15 +02:00
import { logger } from "../logger"
2023-04-16 02:02:22 +02:00
import { ExtendedClient } from "../structures/client"
2023-04-15 22:06:35 +02:00
2023-04-16 02:02:22 +02:00
export async function sendFailureDM(creatorMessage: string, client: ExtendedClient, creatorId?: string): Promise<void> {
2023-06-24 21:09:56 +02:00
if (!creatorId) throw new CustomError('No creator ID present', errorCodes.no_creator_id)
const creator = await client.users.fetch(creatorId)
2023-10-21 14:56:15 +02:00
logger.info(`Creator ${JSON.stringify(creator)}`)
2023-06-24 21:09:56 +02:00
if (creator)
if (!creator.dmChannel)
await creator.createDM()
await creator.dmChannel?.send(creatorMessage)
2023-04-15 22:06:35 +02:00
}