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'})
}
CodePudding user response:
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' });
}