I'm trying to make a discord bot that changes the name of the voice channel to 'game' when you enter and 'shhh' when you leave. The first time I joined and left, both name changes were made very quickly. But the second time, it took around 10 minutes to change the name of the voice channel.
Here is what i'm trying:
client.on('voiceStateUpdate', async (oldMember, newMember) => {
let newUserChannel = newMember.channelID;
let oldUserChannel = oldMember.channelID;
if (newUserChannel === '601225675227267072') {
console.log('joined');
if (newMember.channel.name !== 'game') {
await newMember.channel.setName('game');
}
} else if (oldUserChannel === '601225675227267072') {
console.log('left');
if (oldMember.channel.name !== 'shhh') {
await oldMember.channel.setName('shhh');
}
}
});