From 1422cdfc9ae431c08917f8c23e6c7f109b4d7b65 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 9 Oct 2021 20:19:33 -0400 Subject: [PATCH] add message util class --- src/util/MessageUtil.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/util/MessageUtil.ts diff --git a/src/util/MessageUtil.ts b/src/util/MessageUtil.ts new file mode 100644 index 0000000..e5785f9 --- /dev/null +++ b/src/util/MessageUtil.ts @@ -0,0 +1,10 @@ +import type { MessageContent } from 'eris'; +import type { Client } from '../class'; + +export default class MessageUtil { + static async sendDirectMessage(content: MessageContent, userID: string, client: Client) { + const dmChannel = await client.getDMChannel(userID); + if (!dmChannel) throw new Error(`DM Channel for user ${userID} doesn't exist.`); + return dmChannel.createMessage(content); + } +}