#VC Tracking

32 messages · Page 1 of 1 (latest)

lean locustBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • 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!
analog grotto
#

I'm using DiscordJS v14

real tangle
#

What part of it do you know how to do?

analog grotto
#

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

frigid orchidBOT
#

event (event) Client#voiceStateUpdate
Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.

analog grotto
#

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

night chasm
#

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

real tangle
analog grotto
real tangle
#

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)

analog grotto
#

do you guys think I should just use an array for this

analog grotto
#

how do I get it to not activate on mute and unmute and stuff

night chasm
#

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

analog grotto
night chasm
#

uhh yea i guess, that way you ignore anything else

#

also if (channelId === ChannelId) { makes 0 sense

#

unless ChannelId is defined somewhere else

analog grotto
#

it is

#

sorry but uh what would even be the old voice channel

night chasm
#

oldvoice is your oldstate

analog grotto
#

oh