Guleb
Guleb
DIAdiscord.js - Imagine an app
Created by Guleb on 6/26/2024 in #djs-questions
Unexpected behavior of client.on(Events.VoiceStateUpdate)
I need to check which users are in the channel and which are not after someone leaves. When I subscribe to Events.VoiceStateUpdate and try to console.log the users that are in the channel
client.on(Events.VoiceStateUpdate, (oldState, newState) => {
console.log(oldState.channel?.members.map((m) => m.id));
console.log(newState.channel?.members.map((m) => m.id));
}
client.on(Events.VoiceStateUpdate, (oldState, newState) => {
console.log(oldState.channel?.members.map((m) => m.id));
console.log(newState.channel?.members.map((m) => m.id));
}
it logs
['1020597576728334398']
undefined
['1020597576728334398']
undefined
Although I was expecting to see this
['1020597576728334398', '546703392081313793']
['1020597576728334398']
['1020597576728334398', '546703392081313793']
['1020597576728334398']
Can you please tell me why this is happening?
7 replies