discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
328 stars 112 forks source link

Bot does not connect to voice channel #220

Closed Piipperi closed 2 years ago

Piipperi commented 2 years ago

Please describe the problem you are having in as much detail as possible:

I'm unable to get my bot to join any voice channel. The bot has administrator privileges and I've made sure it has perms to join the voice channel. Real problem is that I get no errors in console, and it does run the code fine. I also tried two different guides on discordjs/voice: the official one and a random one from YouTube (a part of it below), both of the guides had the same result with bot not joining a voice channel and there being no error logs in console.

Include a reproducible code sample here, if possible:

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"); // this one gets logged to the console after the command is triggered.

Further details:

Relevant client options:

Piipperi commented 2 years ago

Found out the issue, it was two simple ones: My path was wrong and the bot was unable to find a proper channel.