Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to grab the id of the channel the bot just made

How do I get the id of the channel that my bot just created?

async execute(interaction, client) {
    interaction.guild.channels
      .create({
        name: "channel",
        type: ChannelType.GuildText,
        permissionOverwrites: [
          {
            id: interaction.guild.id,
            deny: [PermissionsBitField.Flags.SendMessages],
          }
        ],
      })
      interaction.reply({content: 'eh'})
  }

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

create returns a promise, and once resolved, the created Channel, so the following would work for you:

async execute(interaction, client) {
  let channel = await interaction.guild.channels.create({
    name: 'channel',
    type: ChannelType.GuildText,
    permissionOverwrites: [
      {
        id: interaction.guild.id,
        deny: [PermissionsBitField.Flags.SendMessages],
      },
    ],
  });
  // here is the new channel ID
  console.log(channel.id);

  interaction.reply({ content: 'eh' });
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading