Been troubleshooting this for multiple hours now. Issue is that I don't get any error logs from this as the code runs "fine". The bot just doesn't join a voice channel. I have copied the code almost 1:1 from a YouTube tutorial where it worked, and I have tried the official Discord guides as well, and both have the same results.
Here's my code:
const discordVoice = require('@discordjs/voice');
const player = discordVoice.createAudioPlayer();
const resource = discordVoice.createAudioResource(`/sounds/happy/${happySoundsRandom}`);
const connection = discordVoice.joinVoiceChannel({
channelId: channel.id,
guildId: message.guild.id,
adapterCreator: message.guild.voiceAdapterCreator,
});
player.play(resource);
connection.subscribe(player);
console.log("Bot sent to voice")
When I run that by sending a message, I do get that console.log but no results on Discord side. I have readded the bot as an administrator, and made 100% sure the bot has voice channel permissions.
You have to use message.member.voice.channel.id instead of your channel.id