Skip to content

Channel

Channel wraps a Discord channel payload and exposes resource methods for sending messages and editing channel properties.

import { Channel } from "lunibee";
Property Type Description
id string Snowflake ID.
type number Channel type (see ChannelType).
name string | null | undefined Channel name.
guildId string | undefined Guild this channel belongs to.
topic string | null | undefined Channel topic.
parentId string | null | undefined Parent category ID.
nsfw boolean | undefined Whether the channel is age-restricted.
rateLimitPerUser number | undefined Slowmode in seconds.
position number | undefined Sorting position.
createdAt Date Timestamp derived from the snowflake.

Sends a message to this channel.

const msg = await channel.send({ content: "Hello! 🐝" });
// With embeds and components:
await channel.send({
embeds: [embed],
components: [row],
});

Edits this channel’s properties.

await channel.edit({ name: "support", topic: "Get help here." });

Changes only the channel name.

await channel.editName("general");

Changes only the channel topic. Pass null to clear it.

await channel.editTopic("Community announcements and updates.");
await channel.editTopic(null); // clears topic

Moves the channel to a different category. Pass null to remove the parent.

await channel.editParent(categoryId);
await channel.editParent(null);

Deletes this channel.

await channel.delete();

Returns the Discord channel mention string. Automatically used in template literals.

console.log(`Check out ${channel}`); // → "Check out <#123456789>"

Create a support ticket channel

client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand() || interaction.commandName !== "ticket") return;
const guild = client.guilds.get(interaction.guildId!);
const channel = await client.channels.create(interaction.guildId!, {
name: `ticket-${interaction.user.id}`,
topic: `Support ticket for ${interaction.user.username}`,
parent_id: TICKET_CATEGORY_ID,
});
await channel.send({
content: `Welcome ${interaction.user}! Support will be with you shortly.`,
});
await interaction.reply({ content: `Ticket created: ${channel}`, ephemeral: true });
});

Rename a channel from a command

client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand() || interaction.commandName !== "rename") return;
const name = interaction.options.getString("name", true);
const channel = client.channels.get(interaction.channelId);
if (!channel) return interaction.reply({ content: "Channel not found.", ephemeral: true });
await channel.editName(name);
await interaction.reply({ content: `✅ Renamed to **${name}**` });
});