DEV Community

GZYA
GZYA

Posted on • Edited on

2 1

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)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay