mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
20 lines
601 B
TypeScript
20 lines
601 B
TypeScript
import type { Bot } from "../../bot.ts";
|
|
import { DiscordChannel } from "../../types/discord.ts";
|
|
|
|
/** Fetches a single channel object from the api. */
|
|
export async function getChannel(bot: Bot, channelId: bigint) {
|
|
const result = await bot.rest.runMethod<DiscordChannel>(
|
|
bot.rest,
|
|
"GET",
|
|
bot.constants.routes.CHANNEL(channelId),
|
|
);
|
|
|
|
// IF A CHANNEL DOESN'T EXIST, DISCORD RETURNS `{}`
|
|
return result.id
|
|
? bot.transformers.channel(bot, {
|
|
channel: result,
|
|
guildId: result.guild_id ? bot.transformers.snowflake(result.guild_id) : undefined,
|
|
})
|
|
: undefined;
|
|
}
|