cmd.channel.delete

Deletes a channel from the guild.

JavaScript
const { cmd } = require("syntx.js");

await cmd.channel.delete({ channel, reason }, message);

Parameters

ParameterTypeRequiredDescription
channelstring | ChannelYesThe channel ID or a discord.js channel object to delete.
reasonstringNoAudit log reason for the deletion.
messagediscord.js MessageYesA 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.