How do I get every minute every voice user in the channel? Discord.js v13

Clafter

I have created this loop function to get every voice user every minute, but it does not work like I thought.

I get every Minute the same result. If I leve the voice Channel it will still show me my username in the console in the next call. It does not update the result.

function loop(){
    setTimeout(loop, 60000)

    client.guilds.cache.forEach(guild => {
        console.log(`Voice users in ${guild.name}:`)
        guild.voiceStates.cache.forEach(voiceState => {
            if(voiceState.channel){
                console.log(voiceState.member.displayName);
            }
            
        });
    });    
}
Skulaurun Mrusal

Make sure you have GUILD_VOICE_STATES in your client's intents. Otherwise the client is not receiving VOICE_STATE_UPDATE event.

const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_VOICE_STATES"] });

For a complete list of intents and what they do see here.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Discord.js How to make a command to get every member in my voice channel?

How do I get the time elapsed between flags for every user?

Discord.py - How would I get the ID of a Voice Channel?

How do I disconnect a user from a voice channel in discord.js?

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

Discord js / Check if user is in an specific voice Channel

Android how i can do GET request to my server every minute?

How to get Discord.js bot to log variable for every user

How to detect when a user leaves a voice channel in Discord with discord.js V12

How to set a variable to a voice channel specified by a user - Discord.js

How can i get the user's current voice channel ID?

How do I make Discord.JS v13 make a role with Administrator permissions?

How to get owner of a guild in discord.js v13?

How can I upgrade to Discord.js V13?

How do I get the owners of all the guilds in discord.js v13?

How do I check if a user has a specific role? | discord.js v13

How do I save every user to the json file in discord?

How do I get the last message sent in a channel? | discord.js v13

Discord.js | How to get members currently connected to a Voice Channel?

Discord.js v13: how do I stop bot from targeting itself when trying to get a random member's profile picture?

How do you give a user a role by role ID in Discord.JS V13 (latest)

How do I get the guild.id from the server when the bot joins discord.js v13

How to check if the bot has the right to enter the voice Discord.js v13

Discord.js V13: How do I get/ find a category?

Check if member is in a Voice Channel discord.js v13

Join an specific voice channel when the bot is ready in discord.js v13

How can I get the second mention in a message discord.js v13

How do I send a DM to a user in discord.js v13

How do I get user's current voice channel using discord.js?