cmd.channel.create
Creates a new channel in the guild. Supports text, voice, forum, announcement, and category channels, with optional permission overwrites.
const { cmd } = require("syntx.js");
await cmd.channel.create({ data, permissions, returnID }, message);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
data | object | Yes | Channel configuration. See data fields below. |
permissions | PermissionEntry[] | No | Permission overwrites to apply. See permissions below. |
returnID | boolean | No | If true, returns the new channel's ID instead of the channel object. Defaults to false. |
message | discord.js Message | Yes | A guild message or interaction, used to access the guild. |
Data fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The name of the channel. |
type | string | No | Channel type: "text", "voice", "forum", "ad", or "category". Defaults to "text". |
topic | string | No | The channel topic or description. Not available for categories. |
nsfw | boolean | No | Whether the channel is age-restricted. Not available for categories. Defaults to false. |
cooldown | number | No | Slowmode duration in seconds. Not available for categories. |
category | string | No | ID of the parent category. Not available when creating a category itself. |
position | number | No | Position of the channel in the sidebar. |
reason | string | No | Audit log reason for the action. |
Note
The "ad" type creates an announcement channel (also known as a news channel). The fields topic, nsfw, cooldown, category, and position are not allowed when type is "category".
Permissions
Each entry in the permissions array must have the following shape:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The user or role ID to target. Use "everyone" to target @everyone. |
type | string | Yes | Either "user" or "role". |
permissions | object | Yes | A map of Discord permission names to true (allow) or false (deny). |
Permission names follow Discord's naming convention, such as "SEND_MESSAGES", "VIEW_CHANNEL", "MANAGE_MESSAGES", etc.
Returns
discord.js Channel | string
Returns the created channel object by default. If returnID is true, returns the channel ID as a string instead.
Examples
Create a basic text channel
client.command({
name: "createchannel",
content: async (message) => {
const channel = await cmd.channel.create(
{
data: {
name: "general",
topic: "Talk about anything",
nsfw: false,
},
},
message
);
message.reply(`Channel created: <#${channel.id}>`);
},
});Create a channel with permission overwrites
client.command({
name: "privatechannel",
content: async (message) => {
const id = await cmd.channel.create(
{
data: {
name: "staff-only",
type: "text",
reason: "Staff channel setup",
},
permissions: [
{
id: "everyone",
type: "role",
permissions: {
VIEW_CHANNEL: false,
},
},
{
id: "STAFF_ROLE_ID",
type: "role",
permissions: {
VIEW_CHANNEL: true,
SEND_MESSAGES: true,
},
},
],
returnID: true,
},
message
);
message.reply(`Staff channel created with ID: ${id}`);
},
});Create a category channel
client.command({
name: "createcategory",
content: async (message) => {
const category = await cmd.channel.create(
{
data: {
name: "Community",
type: "category",
position: 0,
},
},
message
);
message.reply(`Category created: ${category.name}`);
},
});Warning
The bot must have the Manage Channels permission in the guild for this function to work. If the permission is missing, a SyntxError is thrown.