From 58d1f1c877a54edf6af4d662a5d4e077b8c7ccda Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Sun, 4 Apr 2021 03:34:33 +0000 Subject: [PATCH] fix: check perms only when channel is cached --- src/helpers/messages/get_message.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/helpers/messages/get_message.ts b/src/helpers/messages/get_message.ts index 55ea57ce9..2c3631496 100644 --- a/src/helpers/messages/get_message.ts +++ b/src/helpers/messages/get_message.ts @@ -1,3 +1,4 @@ +import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; import { endpoints } from "../../util/constants.ts"; @@ -5,10 +6,12 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Fetch a single message from the server. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */ export async function getMessage(channelId: string, id: string) { - await requireBotChannelPermissions(channelId, [ - "VIEW_CHANNEL", - "READ_MESSAGE_HISTORY", - ]); + if (await cacheHandlers.has("channels", channelId)) { + await requireBotChannelPermissions(channelId, [ + "VIEW_CHANNEL", + "READ_MESSAGE_HISTORY", + ]); + } const result = (await rest.runMethod(