import { client } from "@/client"; import { ChannelType } from "discord.js"; export async function getTextChannel(id: string, mustBeSendable = true) { const channel = await client.channels.fetch(id); if (!channel) throw new Error(`Channel not found: ${id}`); if (!channel.isTextBased()) throw new Error(`Channel is not text-based: ${id}`); if (!mustBeSendable) return channel; if (!channel.isSendable()) throw new Error(`Channel is not sendable: ${id}`); return channel; } export async function getCategory(id: string) { const channel = await client.channels.fetch(id); if (!channel) throw new Error(`Category not found: ${id}`); if (channel.type !== ChannelType.GuildCategory) throw new Error(`Channel is not a category: ${id}`); return channel; }