Cant get user's voice channel

I'm stumped, when I try to get the users voice channel everything returns null (yes the user is in a vc), but I have the intents so what is going on? Here is member.voice I logged this after I call await guild.members.fetch(user.id)
VoiceState {
guild: <ref *1> Guild {},
id: '778409873573412874',
serverDeaf: null,
serverMute: null,
selfDeaf: null,
selfMute: null,
selfVideo: null,
sessionId: null,
streaming: null,
channelId: null,
suppress: null,
requestToSpeakTimestamp: null
}
VoiceState {
guild: <ref *1> Guild {},
id: '778409873573412874',
serverDeaf: null,
serverMute: null,
selfDeaf: null,
selfMute: null,
selfVideo: null,
sessionId: null,
streaming: null,
channelId: null,
suppress: null,
requestToSpeakTimestamp: null
}
Here is my client
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages
],
partials: [
Partials.User,
Partials.Channel,
Partials.GuildMember,
Partials.Message,
Partials.Reaction,
Partials.GuildScheduledEvent,
Partials.ThreadMember
]
});
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages
],
partials: [
Partials.User,
Partials.Channel,
Partials.GuildMember,
Partials.Message,
Partials.Reaction,
Partials.GuildScheduledEvent,
Partials.ThreadMember
]
});
8 Replies
d.js toolkit
d.js toolkit5mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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
Prince527#1270
Prince527#1270OP5mo ago
I might have put this in the wrong channel, oh no... welp il leave it, I think its fine
duck
duck5mo ago
this is the correct channel, #djs-voice is for @discordjs/voice if that's what you were thinking
I have the intents
I don't see the GuildVoiceStates intent sorry I appear to be blind you should double check - that's the correct guild for the channel they're connected to - that's the correct user if these are correct, please share more of your code since there isn't really anything else required
Prince527#1270
Prince527#1270OP5mo ago
I checked (guild id and user id) and nothing still cant give me the channel. This is the code im running, im just getting the guild and member then logging the voice
async function test() {
const guild = await client.guilds.fetch("949446207418269706");

const member = await guild.members.fetch("778409873573412874");

console.log(member.voice)
}
async function test() {
const guild = await client.guilds.fetch("949446207418269706");

const member = await guild.members.fetch("778409873573412874");

console.log(member.voice)
}
My logging every time gives me the same response
VoiceState {
guild: <ref *1> Guild {},
id: '778409873573412874', // <-- my server id
serverDeaf: null,
serverMute: null,
selfDeaf: null,
selfMute: null,
selfVideo: null,
sessionId: null,
streaming: null,
channelId: null, // <-- this is null, like it got no data
suppress: null,
requestToSpeakTimestamp: null
}
VoiceState {
guild: <ref *1> Guild {},
id: '778409873573412874', // <-- my server id
serverDeaf: null,
serverMute: null,
selfDeaf: null,
selfMute: null,
selfVideo: null,
sessionId: null,
streaming: null,
channelId: null, // <-- this is null, like it got no data
suppress: null,
requestToSpeakTimestamp: null
}
The image here shows me and my (other) bot in a vc, im trying to use another bot to get the channel that Lamar is in
You can see me and my bot (thats the user id in fetching, I also tried my id same output)
duck
duck5mo ago
just to confirm, if you log the voiceStateUpdate event, is it able to detect your other bot joining/leaving?
Prince527#1270
Prince527#1270OP5mo ago
yes I can confirm, I see the bot joining and leaving in the event just not when I fetch him
duck
duck5mo ago
then you should probably triple check that the guild you're fetching is the correct guild you can also specifically log newState.guild.id from the voiceStateUpdate event
Prince527#1270
Prince527#1270OP5mo ago
omg bro I found it, my client was not fully ready when I was fetching 🤦‍♂️ I ran the function in the ready event and boom the channel id well uh, thanks for helping me 👍, im gonna go back to debugging the original thing that caused all of this a broken if statement
Want results from more Discord servers?
Add your server