create channel discord.js code example

Example 1: discord js channel connect

client.on('message', message => {
    if (message.author.bot) return;
    if (message.channel.id === '2ND CHANNEL ID'){
        const Messager = message.author.username;
        const GlobalMessage = message.content;
        const GlobalSender = client.channels.cache.find(channel => channel.id === '1ST CHANNEL ID')
        const EmoGlobalChatEmbed = new Discord.MessageEmbed()
            .setColor('#b700ff')
            .setTitle("Message From : " + Messager)
            .addField(" \u200B ", GlobalMessage)
            .setFooter('Best, Emo', 'https://i.ibb.co/qjgWyQP/emo.png');
            message.channel.send("Message Executed")
        message.channel.send(EmoGlobalChatEmbed);
        GlobalSender.send("**New Message : **")
        GlobalSender.send(EmoGlobalChatEmbed)
        message.delete()
    } else if (message.channel.id === '1ST CHANNEL ID') {
        const Messager = message.author.username;
        const GlobalMessage = message.content;
        const GlobalSender = client.channels.cache.find(channel => channel.id === '2ND CHANNEL ID')
        const EmoGlobalChatEmbed = new Discord.MessageEmbed()
            .setColor('#b700ff')
            .setTitle("Message From : " + Messager)
            .addField(" \u200B ", GlobalMessage)
            .setFooter('Best, Emo', 'https://i.ibb.co/qjgWyQP/emo.png');
        message.channel.send("Message Executed")
        message.channel.send(EmoGlobalChatEmbed);
        GlobalSender.send("**New Message : **")
        GlobalSender.send(EmoGlobalChatEmbed)
        message.delete()
    }
})

Example 2: discord.js create channel

// Create a new text channel
guild.channels.create('new-general', { reason: 'Needed a cool new channel' })
  .then(console.log)
  .catch(console.error);

// Create a new channel with permission overwrites
guild.channels.create('new-voice', {
  type: 'voice',
  permissionOverwrites: [
     {
       id: message.author.id,
       deny: ['VIEW_CHANNEL'],
    },
  ],
})

Example 3: discord.js custom create channel

let channelName = args.slice(0).join(' '); //Arguments to set the channel name
message.guild.channels.create(channelName, {
        type: "text", //This create a text channel, you can make a voice one too, by changing "text" to "voice"
        permissionOverwrites: [
           {
             id: message.guild.roles.everyone, //To make it be seen by a certain role, user an ID instead
             allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'], //Allow permissions
             deny: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGE_HISTORY'] //Deny permissions
		   }
        ],
      })

//Note, you cant have, for example, VIEW_CHANNEL, in both allow and deny.