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
+7 -4
View File
@@ -1,3 +1,4 @@
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts"; import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts"; import { structures } from "../../structures/mod.ts";
import { endpoints } from "../../util/constants.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 */ /** Fetch a single message from the server. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */
export async function getMessage(channelId: string, id: string) { export async function getMessage(channelId: string, id: string) {
await requireBotChannelPermissions(channelId, [ if (await cacheHandlers.has("channels", channelId)) {
"VIEW_CHANNEL", await requireBotChannelPermissions(channelId, [
"READ_MESSAGE_HISTORY", "VIEW_CHANNEL",
]); "READ_MESSAGE_HISTORY",
]);
}
const result = const result =
(await rest.runMethod( (await rest.runMethod(