So, I'm currently working on a "temporary channels" module for my bot. When a user with a certain rank does !newvc, the bot creates a private voice channel that they can use, add people, and when everyone leaves, it gets automatically deleted after some time.
Everything was working fine, but I've noticed a bug that I can't find the reason behind why it happens. Basically, when you first use the command all works fine, the channel is made, you get added and it's moved to the category. But if you use it again, let's say a minute later you don't get added. The channel is made, set as private but you message.member doesn't get added. Then it again does and doesn't, You get the point right?
I honestly can't find a reason why it does it and the only thing I can think of is something to do with Discord's API.
Here's my code
let member = message.member
user = member.user
message.delete()
message.guild.createChannel(`⭐${member.user.username}'s Room`, 'voice', [{
id: message.guild.id,
deny: ['CONNECT', 'SPEAK', 'PRIORITY_SPEAKER']
}]).then(channel => {
channel.overwritePermissions(member, {
CONNECT: true,
USE_VAD: true,
PRIORITY_SPEAKER: true
})
channel.setParent('567718414454358026')
})
let privatevc = new Discord.RichEmbed()
.setDescription(':white_check_mark: Successfully created a voice channel!')
.setColor(config.green)
message.channel.send({ embed: privatevc }).then(msg => msg.delete(10000))
FYI: My Discord.JS version is 11.4 (didn't had time to update it, due to work)