Get Id After Discord.js Channel Creation
I'm trying to create a discord bot with discord.js. Basically, I would like to create a category and get the id and then create another channel that takes the category as parent bu
Solution 1:
guild.create
method returns a Promise
. To operate with data from Promise it should be resolved, as Promise is about asyncronous functions. So here are 2 options: create another channel in .then block
const tempo1 = guild.channels.create('Channel Tempo', { type: 'category' }).then(result => {
console.log('Here is channel id', result.id)
//create another channel here
})
or use async|await constructions,e.g.
asyncfunctioncreateChannel() {
const tempo1= await guild.channels.create('Channel Tempo', { type: 'category' })
console.log(result)
console.log(tempo1.id)
return tempo1
}
createChannel()
Post a Comment for "Get Id After Discord.js Channel Creation"