discordjs / voice

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

trying to establish a connection always fail for timeout while waiting status to be ready #203

Closed dahool closed 3 years ago

dahool commented 3 years ago

I'm trying to establish a connection to a voice channel. I can see the bot actually connects to the channel, but it always get aborted after timeout because the connection never switch to ready, it always stay at signalling

async function connectToChannel(channel) {
  const connection = joinVoiceChannel({
    channelId: channel.id,
    guildId: channel.guild.id,
    adapterCreator: channel.guild.voiceAdapterCreator,
  });
  try {
    // this always fail with timeout
    await entersState(connection, VoiceConnectionStatus.Ready, 30_000);
    return connection;
  } catch (error) {
    connection.destroy();
    throw error;
  }
}

Further details:

iim-ayush commented 3 years ago

You need GUILD_VOICE_STATES intent also.

Add that and try again.

dahool commented 3 years ago

Adding GUILD_VOICE_STATES worked. Could that be added to the documentation please?

iim-ayush commented 3 years ago

@dahool

discord.js docs states very clearly about this. As discordjs/voice is a separate package, so it doesn't mention separately.

image

Please close this issue.

dahool commented 3 years ago

true, but since is a separate package with its own documentation, it would be nice if it is documented there too.