mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
* 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>
20 lines
609 B
TypeScript
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;
|
|
}
|