node-event-bot/server/helper/sendFailureDM.ts

13 lines
496 B
TypeScript
Raw Normal View History

2022-05-05 21:39:53 +02:00
import { client } from "../.."
import { CustomError, errorCodes } from "../interfaces"
export async function sendFailureDM(creatorMessage: string, creatorId?: string): Promise<void> {
if (!creatorId) throw new CustomError('No creator ID present', errorCodes.no_creator_id)
const creator = await client.users.fetch(creatorId)
console.log(`Creator ${JSON.stringify(creator)}`)
if (creator)
if (!creator.dmChannel)
await creator.createDM()
await creator.dmChannel?.send(creatorMessage)
}