DEV Community

captainjuzo
captainjuzo

Posted on • Updated on

problems occurred when i try to do a discord bot autoVoiceChannel

Hello i try to create a Auto Voice channel .
When you join a channel (New channel)
the bot gonna create a new channel like (First-Channel)
and when you leave he gonna delete him

To create a new channel i need the

bot.on('message', async msg => {

msg.guild.createChannel('First-channel', "voice")

}

But i want to do

bot.on('voiceStateUpdate', async (oldMember, newMember, ) => {

let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel

if (oldUserChannel === undefined && newUserChannel !== undefined) {

// here is when you join a channel and i want to put the
msg.guild.createChannel('First-Channel', "voice")

here but is not possible can you help me ?

} else if (newUserChannel === undefined) {

// Here is when you leave channel

}

})

Thanks you and sry for my bad english

Top comments (0)