cmd.channel.delete
Deletes a channel from the guild.
JavaScript
const { cmd } = require("syntx.js");
await cmd.channel.delete({ channel, reason }, message);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
channel | string | Channel | Yes | The channel ID or a discord.js channel object to delete. |
reason | string | No | Audit log reason for the deletion. |
message | discord.js Message | Yes | A guild message or interaction, used to access the guild. |
Returns
true once the channel has been successfully deleted.
Example
JavaScript
client.command({
name: "deletechannel",
content: async (message) => {
const channelId = cmd.channel.mentioned(message, 1);
if (!channelId) return message.reply("Please mention a channel.");
await cmd.channel.delete(
{
channel: channelId,
reason: `Deleted by ${message.author.tag}`,
},
message
);
message.reply("Channel deleted.");
},
});Warning
The bot must have the Manage Channels permission for the target channel. If the channel cannot be found in the guild's cache or the bot lacks permission, a SyntxError is thrown.