member.voice.channelId undefined on client ready.

hola senores, any reason why my bot can't "see" a member's voice channel data when it turns on? for example, the channel id is undefined until said user leaves and rejoins the channel. is this a caching issue? and if so, how can I update the cache immediately after turning the bot on? thanks in advance!
6 Replies
d.js toolkit
d.js toolkit2mo ago
- What are your intents? GuildVoiceStates is required to receive voice data! - Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice. - Try looking at common examples: https://github.com/discordjs/voice-examples. - 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! - Marked as resolved by OP
Amgelo
Amgelo2mo ago
members and their data aren't received on ready, and as such aren't available in the cache if you want to know all members' data in ready, you need to fetch them
d.js docs
d.js docs2mo ago
:method: GuildMemberManager#fetch() @14.16.3 Fetches member(s) from a guild.
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
Amgelo
Amgelo2mo ago
aditionally to keep the voice cache updated you need the intent
d.js docs
d.js docs2mo ago
:dtypes: v10: GatewayIntentBits - GuildVoiceStates read more
SpecialNuggets
SpecialNuggetsOP2mo ago
fixed, but it should be noted that I had to use await interaction.member.voice.fetch() in client.on interaction create as GuildVoiceStates does not allow pulling the entire guild's member data
Want results from more Discord servers?
Add your server