#Discordjs v14 won't join channel when command is being used

23 messages · Page 1 of 1 (latest)

shrewd questBOT
#

• 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.

celest swan
proper zodiac
#

On line 14, if you change channelId: client.voiceChannel.id, to channelId: channel.id, it works fine, but In-App you're gonna get an error saying the bot didn't respond because you're not replying to the interaction.

celest swan
#

I changed it and got no error code, but a message from the bot saying the application didn't respond

proper zodiac
#

Did it join the voice channel?

celest swan
#

no

proper zodiac
#

Odd, it starts working when i change that line, again you are going to get this error:

#

as you aren't actually responding to the interaction with a reply

celest swan
#

hmm

#

am i fetching the voice channel id wrong?

proper zodiac
#

In the original message yes, if you changed line 14 it should look like this

const { SlashCommandBuilder, ChannelType} = require('discord.js');
const { joinVoiceChannel, VoiceConnectionStatus, AudioPlayerStatus, VoiceConnection, getVoiceConnection, createAudioResource, createAudioPlayer} = require('@discordjs/voice')

module.exports = {
    data: new SlashCommandBuilder()
        .setName('join')
        .setDescription('Get discord bot to join the vc! (no leave command yet)')
        .addChannelOption(option => option.setName('channel').setDescription('The channel to join').setRequired(true).addChannelTypes(ChannelType.GuildVoice)),
    async execute(interaction) {

        const channel = interaction.options.getChannel('channel');

        const connection = joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator,
        }); 
        console.log(getVoiceConnection)
    },
};
celest swan
#

i did

proper zodiac
#

Can you add

connection.on('stateChange', (oldState, newState) => {
    console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`);
});

after const connection
and GuildVoiceStates to your gateway intents and post the console output when the command is ran?

This is mainly to see if it's getting caught connecting or in some other state.

Meaning update it to

const connection = joinVoiceChannel({
    channelId: channel.id,
    guildId: channel.guild.id,
    adapterCreator: channel.guild.voiceAdapterCreator,
});
connection.on('stateChange', (oldState, newState) => {
    console.log(`Connection transitioned from ${oldState.status} to ${newState.status}`);
});
celest swan
#

okay

#

i did it, and nothing changed

proper zodiac
#

What did it output in console?

celest swan
#

ƒ getVoiceConnection(guildId, group = "default") {
return getVoiceConnections(group)?.get(guildId);
}

#

that was from the command in line 21

proper zodiac
#

Now I'm confused... The code is definitely running but it sounds like its not trying to join

celest swan
#

let me check something

#

sorry! it was a permission issue on my end

#

thank you!