So, basically I have some code setup and I don't see the issue with the code. But basically what I want it to do is if the previous voice channel of the member that switched channels was "DO NOT DISTURB" it will move them back to the "DO NOT DISTURB" voice channel. What have I done wrong? I get 0 errors in console.
client.on('voiceStateUpdate', async (oldState, newState) => {
let newUserChannel = newState.channel;
let oldUserChannel = oldState.channel;
if(oldUserChannel.id === "894024223088050176") {
var dndChannel = oldState.guild.channels.cache.find(ch => ch.type === "voice" && ch.name === "DO NOT DISTURB")
newState.member.voice.setChannel(dndChannel)
}
});
Double check if your channelid in the if condition is right and use
Guild.channels.fetch(channelId)
insted of Guild.channels.cache.find().