fix: check perms only when channel is cached

This commit is contained in:
Skillz4Killz
2021-04-04 03:34:33 +00:00
committed by GitHub
parent cc46698245
commit 58d1f1c877
+3
View File
@@ -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) {
if (await cacheHandlers.has("channels", channelId)) {
await requireBotChannelPermissions(channelId, [
"VIEW_CHANNEL",
"READ_MESSAGE_HISTORY",
]);
}
const result =
(await rest.runMethod(