mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
23 lines
893 B
TypeScript
23 lines
893 B
TypeScript
// Loaded from https://deno.land/x/discordeno@11.0.0-rc.2/src/helpers/channels/get_stage_instance.ts
|
|
|
|
|
|
import { cacheHandlers } from "../../cache.ts";
|
|
import { rest } from "../../rest/rest.ts";
|
|
import { ChannelTypes } from "../../types/channels/channel_types.ts";
|
|
import type { StageInstance } from "../../types/channels/stage_instance.ts";
|
|
import { Errors } from "../../types/discordeno/errors.ts";
|
|
import { endpoints } from "../../util/constants.ts";
|
|
|
|
/** Gets the stage instance associated with the Stage channel, if it exists. */
|
|
export async function getStageInstance(channelId: bigint) {
|
|
const channel = await cacheHandlers.get("channels", channelId);
|
|
|
|
if (channel) {
|
|
if (channel.type !== ChannelTypes.GuildStageVoice) {
|
|
throw new Error(Errors.CHANNEL_NOT_STAGE_VOICE);
|
|
}
|
|
}
|
|
|
|
return await rest.runMethod<StageInstance>("get", endpoints.STAGE_INSTANCE(channelId));
|
|
}
|