discord.js GuildChannel code example

Example 1: Find channel discord js

// Insert the Channel ID in the brackets. TO find that, right click the
// channel and select "Copy ID". Discord Developer must be on.
let channel = message.guild.channels.cache.get(channelid)

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 channel send

const user = <client>.users.cache.get('<id>');
user.send('<content>');

Example 4: discord js channel send

const channel = <client>.channels.cache.get('<id>');
channel.send('<content>');