Files
discordeno/helpers/channels/getChannel.ts
T
Skillz4KillzandLTS20050703 5a4fef855e Proxy delete channel tests (#2174)
* feat: delete channel tests

* fix: use new tests in ci

* Update testss/deps.ts

Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>

Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
2022-05-08 09:57:06 -04:00

20 lines
609 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.endpoints.CHANNEL_BASE(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;
}