Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with voice connections #1595

Closed
1 task
YinglunQ opened this issue Jun 14, 2017 · 8 comments
Closed
1 task

Issue with voice connections #1595

YinglunQ opened this issue Jun 14, 2017 · 8 comments

Comments

@YinglunQ
Copy link

YinglunQ commented Jun 14, 2017

Please describe the problem you are having in as much detail as possible:
In the server setting, my bot has permission to connect. However, I set up a specific voice channel which disabled everyone's permission to connect (which should overwrite the server permission). But when I log voiceChannel.joinable, it is returning true, so my bot still tries to join, and it stuck at VoiceStatus 2(AUTHENTICATING). After about 15 seconds, I get the following unhandled error and the program crashed:

events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: Error: Connection not established within 15 seconds.
    at VoiceConnection.authenticateFailed (/Users/user/Documents/NodeJS/MusicBot/node_modules/discord.js/src/client/voice/VoiceConnection.js:257:26)
    at connectTimeout.client.setTimeout (/Users/user/Documents/NodeJS/MusicBot/node_modules/discord.js/src/client/voice/VoiceConnection.js:278:18)
    at Timeout.setTimeout (/Users/user/Documents/NodeJS/MusicBot/node_modules/discord.js/src/client/Client.js:446:7)
    at ontimeout (timers.js:488:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:283:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! musicbot@1.0.0 start: `node --optimize_for_size src/main.js`
npm ERR! Exit status 1

Include a reproducible code sample here, if possible:

onst Discord = require('discord.js');
const client = new Discord.Client();

client.login('token here');

client.on('message', message => {
  // Voice only works in guilds, if the message does not come from a guild,
  // we ignore it
  if (!message.guild) return;

  if (message.content === '/join') {
    // Only try to join the sender's voice channel if they are in one themselves
    if (message.member.voiceChannel) {
      // check if there is already a voice connection
      if (message.member.voiceChannel.connection) {
        console.log('conn status: ' + message.member.voiceChannel.connection.status);
      }
      console.log('is joinable: ' + message.member.voiceChannel.joinable);
      if (message.member.voiceChannel.joinable) {
        message.member.voiceChannel.join()
          .then(connection => { // Connection is an instance of VoiceConnection
            message.reply('I have successfully connected to the channel!');
          })
          .catch(console.error);
      }
    } else {
      message.reply('You need to join a voice channel first!');
    }
  }
});

Further details:

  • discord.js version: Master
  • node.js version: 8.0.0
  • Operating system: Windows 10
  • Priority this issue should have – high
  • I have also tested the issue on latest master, commit hash:
@aemino
Copy link
Contributor

aemino commented Jun 14, 2017

Joinable is a property, not a function.

@YinglunQ
Copy link
Author

YinglunQ commented Jun 14, 2017

@aemino oops sorry typo in my sample code. But in my actual code, i didn't put brackets.

@iCrawl iCrawl changed the title voiceChannel.joinable is returning true even cannot connect Issue with voice connections Jun 15, 2017
@telunc
Copy link

telunc commented Jun 15, 2017

There are two issues that occurred here:

  • Joining voice channel caused the program to exit with status 1
  • PermissionsFor is not giving the correct values

Status 1
I made a pull request for exiting with status 1. It was an unhandled event that never passed to the failed event. The latest master branch is crashing on join for me as well. Hopefully, the pr will be merged or this issue get patched soon.

Permissions
Please refer to VoiceChannel's joinable. The problem is that permissionsFor is not giving the correct values. I can confirm that permissionFor is not working properly in the latest master branch. It is not just checking for voice channel permission; it's happening for text channel permission as well.

VoiceChannel's Joinable

this.permissionsFor(this.client.user).has('CONNECT')

@FireController1847
Copy link
Contributor

I've noticed this as well, as well on permissionsFor. I always check if my bot has permission to send messages in the channel and I've gotten multiple errors from that line (in exclusive testing) of bot having permission to send messages.

@iCrawl
Copy link
Member

iCrawl commented Jun 15, 2017

Found the issue. Gonna be fixed in the next few commits. I'll leave a message and close the issue when its done.
This is only an issue on master btw.

@MeesMaas
Copy link

MeesMaas commented Jun 21, 2017

I experience this issue as well:

events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: Error: Connection not established within 15 seconds.
    at VoiceConnection.authenticateFailed (/home/mees/MeMezBot/node_modules/discord.js/src/client/voice/VoiceConnection.js:256:26)
    at connectTimeout.client.setTimeout (/home/mees/MeMezBot/node_modules/discord.js/src/client/voice/VoiceConnection.js:277:18)
    at Timeout.setTimeout (/home/mees/MeMezBot/node_modules/discord.js/src/client/Client.js:422:7)
    at ontimeout (timers.js:488:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:283:5)

@amishshah
Copy link
Member

Can you see if the above PR (#1601) fixed your issue? Thanks.

@YinglunQ
Copy link
Author

@hydrabolt I think the issue is fixed since I don't see any of those errors anymore. Thanks a lot!

@telunc telunc mentioned this issue Jun 27, 2017
1 task
@iCrawl iCrawl closed this as completed Jul 3, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants