[SOLVED] 🤦Bot doesnt join the voice channel
So I have the following code, when its being executed, the bot doesnt join the voice channel.
client.channelId is defined in the main file as a channel ID.
Am i doing something wrong? There are no errors in the console and the file is being ran (ive added
console.log
s to see if it works and it does).
Idk if its an intent issue but here are my intents:
10 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.discord.js
version is 14.11.0 and @discordjs/voice
is 0.16.0
Also if the resource can't be created (like if the file doesn't exist), would it throw an error?Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
The command isn't being ran in a voice channel. client.channelId is the voice ID copy pasted from discord. (yes it's a string)
Can anyone help me? The bot isnt joining the voice channel at all. Am i suppose to do anything else?
The voice channel ID is correct, there are no errors at all, and the code above is what I have that I'm trying to get it to work. The file runs but the bot doesnt join the voice channel
If it helps im trying to play a local file
how are you confirming the id is correct?
if you log
client.channels.cache.get(client.channelId)
do you receive the channel object?
how have you confirmed that this executes in the first place?
could you listen to the debug
and error
events on your connection
and log the results?
and side question, why are you specifying WebmOpus
for your stream type?To debug your voice connection and player:
• Use
debug: true
when creating your VoiceConnection
and AudioPlayer
• Add an event listener to the <VoiceConnection> and the <AudioPlayer>:
• Add an error
listener to the stream you are passing to the resource:
Note: The <>
represents classes that need to be adapted to their respective name in your code
Oh my God...
That was the issue
I was using the wrong property
It was supposed to be
client.voiceChannel
... I am so sorry for wasting your time
But may I ask, shouldn't it throw an error if the channel is not found? Or can I suggest this?Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
@discordjs/voice
doesn't resolve the channel id to a Channel object through discord.js
before attempting to connect since it's intended to be standalone and usable with libraries other than discord.js
beyond that, dapi doesn't send an error (or any response for that matter) for an invalid channel id in the initial voice state update, so there isn't really a way to distinguish the channel id being incorrect from the connection simply timing out
it would be far easier for you to validate the id
and realistically you should also handle the connection timing outGot it đź‘Ť
I guess I should resolve the channel id into a channel object and access the Id from there to ensure that the channel does exist