fix: bad channel.thread handling

This commit is contained in:
Skillz4Killz
2021-06-18 15:47:34 +00:00
committed by GitHub
parent 72f0836b7b
commit 5e4efd0f37
9 changed files with 53 additions and 44 deletions
@@ -0,0 +1,15 @@
import { cacheHandlers } from "../../../cache.ts";
import { rest } from "../../../rest/rest.ts";
import { endpoints } from "../../../util/constants.ts";
import { requireBotGuildPermissions } from "../../../util/permissions.ts";
/** Delete a thread in your server. Bot needs MANAGE_THREADS permissions in the server. */
export async function deleteThread(threadId: bigint, reason?: string) {
const thread = await cacheHandlers.get("threads", threadId);
if (thread) {
const channel = await cacheHandlers.get("channels", thread?.channelId);
if (channel?.guildId) await requireBotGuildPermissions(channel.guildId, ["MANAGE_THREADS"]);
}
return await rest.runMethod("delete", endpoints.CHANNEL_BASE(threadId), { reason });
}