简体   繁体   中英

Discord.js - Get last user that left a voice channel

I'm trying to get the last user that left a voice channel.

I've found the client.on('voiceStateUpdate', async (oldState, newState)=>{}) event that allows me to detect when a member leaves or joins the VC. However, I cannot find a way to determine which guild member has joined/left. I know that I can get the channel from oldState.channel, but I can't get the user who left in any way. I'd like to avoid managing a global state of all users in VC, is there any way to do this via event-driven logic alone?

Thanks

According to the documentation , the oldState and newState objects are both VoiceState objects. VoiceState has the property .id , which you can use to identify the user who has left or joined. There seems to also be the field .member , which has more data. I'm unsure which would be preferable in this context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM