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

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

Closed dahool closed 2 years ago

dahool commented 2 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 2 years ago

You need GUILD_VOICE_STATES intent also.

Add that and try again.

dahool commented 2 years ago

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

iim-ayush commented 2 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 2 years ago

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