- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - Not a discord.js issue? Check out #1081585952654360687.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
#VC Tracking
32 messages · Page 1 of 1 (latest)
I'm using DiscordJS v14
What part of it do you know how to do?
I need to know how I can tell the bot when a person joins the vc and how to tell it to update in real time
so like every minute that a person is in vc back in the days we would only use the join and leave to calculate the total amount of time that someone was in VC
(event) Client#voiceStateUpdate
Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.
yeah thats the old school way
oh hold on
I think I might see what you're saying/hinting at
I could do a loop maybe of every second and then check the time then do it
yea i mean you dont really need to use voice if the only thing you care about is knowing when someone joins or leaves a vc
you can have a collection or map with a user id and a timestamp
Map(userid, joinedvcTimestamp) then when a user leaves a vc, check if there is a timestamp available, create another one with the current time and do some math to calculate whatever value you want
What’s old school about that? That’s literally the event that emits when they join or leave
also says it emits when they mute and unmute
But you asked about when they join and leave. So that’s how you get informed about that. Then check if the channelId on oldState is null and newState isn’t (join) or other way around (leave)
do you guys think I should just use an array for this
how do I get it to not activate on mute and unmute and stuff
you are only interested on knowing whether or not they leave or join a vc
use the old and new voicestate to check whether or not voicestate.channel is null or not and proceed according to that
if (!oldvoice.channel && newvoice.channel) means they joined a vc
if you negate that statement it means they left
are you saying to nest them in this
uhh yea i guess, that way you ignore anything else
also if (channelId === ChannelId) { makes 0 sense
unless ChannelId is defined somewhere else
oldvoice is your oldstate
oh