From 30082e91db3f1d44e3ecf12874737f037e31a59b Mon Sep 17 00:00:00 2001 From: Neko Life Date: Sun, 16 May 2021 09:53:48 +0000 Subject: [PATCH] trySend update --- resources/functions.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/functions.js b/resources/functions.js index e254b1f..4bc976a 100644 --- a/resources/functions.js +++ b/resources/functions.js @@ -1,6 +1,6 @@ 'use strict'; -const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions } = require('discord.js'); +const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions, Channel } = require('discord.js'); const { defaultErrorLogChannel } = require("../config.json"); const { database } = require("../database/mongo"); const getColor = require('./getColor'); @@ -203,7 +203,7 @@ function noPerm(msg) { /** * Send message * @param {Client} client - (this.client) - * @param {Message | String} msg Message object | channel_ID + * @param {Message | String | Channel} msg Message object | channel_ID * @param {MessageOptions} content - ({content:content,optionblabla}) * @returns {Promise} Sent message object */ @@ -213,7 +213,11 @@ async function trySend(client, msg, content) { if (msg?.channel) { msgOf = msg.channel; } else { - msgOf = client.channels.cache.get(msg); + if (typeof msg === "string") { + msgOf = client.channels.cache.get(msg); + } else { + msgOf = msg; + } } const sentMes = await msgOf.send(content) .catch((e) => {