#Discordjs v14 won't join channel when command is being used
23 messages · Page 1 of 1 (latest)
node version: v18.16.0
discordjs version: [email protected]
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.
I changed it and got no error code, but a message from the bot saying the application didn't respond
Did it join the voice channel?
no
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
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)
},
};
i did
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}`);
});
What did it output in console?
ƒ getVoiceConnection(guildId, group = "default") {
return getVoiceConnections(group)?.get(guildId);
}
that was from the command in line 21
Now I'm confused... The code is definitely running but it sounds like its not trying to join