{"action":"created","issue":{"url":"https://api.github.com/repos/discordjs/discord.js/issues/2578","repository_url":"https://api.github.com/repos/discordjs/discord.js","labels_url":"https://api.github.com/repos/discordjs/discord.js/issues/2578/labels{/name}","comments_url":"https://api.github.com/repos/discordjs/discord.js/issues/2578/comments","events_url":"https://api.github.com/repos/discordjs/discord.js/issues/2578/events","html_url":"https://github.com/discordjs/discord.js/issues/2578","id":328900337,"node_id":"MDU6SXNzdWUzMjg5MDAzMzc=","number":2578,"title":"<Voice Channel>.join(); Timeouts and Cache Problems.","user":{"login":"Deivu","id":36309350,"node_id":"MDQ6VXNlcjM2MzA5MzUw","avatar_url":"https://avatars1.githubusercontent.com/u/36309350?v=4","gravatar_id":"","url":"https://api.github.com/users/Deivu","html_url":"https://github.com/Deivu","followers_url":"https://api.github.com/users/Deivu/followers","following_url":"https://api.github.com/users/Deivu/following{/other_user}","gists_url":"https://api.github.com/users/Deivu/gists{/gist_id}","starred_url":"https://api.github.com/users/Deivu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Deivu/subscriptions","organizations_url":"https://api.github.com/users/Deivu/orgs","repos_url":"https://api.github.com/users/Deivu/repos","events_url":"https://api.github.com/users/Deivu/events{/privacy}","received_events_url":"https://api.github.com/users/Deivu/received_events","type":"User","site_admin":false},"labels":[{"id":305464157,"node_id":"MDU6TGFiZWwzMDU0NjQxNTc=","url":"https://api.github.com/repos/discordjs/discord.js/labels/p:%20low","name":"p: low","color":"ffc9c9","default":false},{"id":305742855,"node_id":"MDU6TGFiZWwzMDU3NDI4NTU=","url":"https://api.github.com/repos/discordjs/discord.js/labels/s:%20potentially%20fixed","name":"s: potentially fixed","color":"eebcff","default":false},{"id":440307444,"node_id":"MDU6TGFiZWw0NDAzMDc0NDQ=","url":"https://api.github.com/repos/discordjs/discord.js/labels/t:%20voice","name":"t: voice","color":"31e097","default":false},{"id":246168563,"node_id":"MDU6TGFiZWwyNDYxNjg1NjM=","url":"https://api.github.com/repos/discordjs/discord.js/labels/type:%20bug","name":"type: bug","color":"af310e","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-06-04T03:55:46Z","updated_at":"2018-08-25T04:31:38Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nIf you need help with discord.js installation or usage, please go to the discord.js Discord server instead:\r\n  https://discord.gg/bRCvFy9\r\nThis issue tracker is only for bug reports and enhancement suggestions. You won't receive any basic help here.\r\n-->\r\n\r\n**Please describe the problem you are having in as much detail as possible:**\r\nWhen the bot fails to join the voiceChannel with timeouts, the voiceChannel stays in client.voiceConnection even though the bot isn't really on that voiceChannel, breaking the whole voice part of my bot in that guild. This timeout error also can't be used with .catch also. so I used process.on(error) to catch it. In order to get the voice functionality on the guild to be back, I did a manual checking on client.on(ready) that automatically tries to leave the voice channel then delete the cache of it.\r\n```js\r\nsetInterval(() => {\r\n\t\tlet connections = client.voiceConnections\r\n\t\tconnections.forEach(guilds => {\r\n\t\t\tlet guildID = guilds.channel.guild.id;\r\n\t\t\tlet musicRadio = bot.moeCheck.has(guildID);\r\n\t\t\tlet voiceBox = bot.voiceCheck.has(guildID);\r\n\t\t\tlet musicQueue = bot.queue.has(guildID)\r\n\t\t\tif (musicRadio || voiceBox || musicQueue) return;\r\n\t\t\telse {\r\n\t\t\t    try {\r\n\t\t\t\t    guilds.channel.leave();\r\n\t\t\t\t    client.voiceConnections.delete(guildID)\r\n\t\t\t    } catch (e) {\r\n\t\t\t        console.error(e)\r\n\t\t\t    }\r\n\t\t    }\r\n\t\t});\r\n\t}, 15000);\r\n```\r\n\r\n**Include a reproducible code sample here, if possible:**\r\nAdditional note, setting something in a map after trying to join the channel can also cause this.\r\n```js\r\nvoiceChannel.join().then(voiceConnected => {\r\n     map.set(key, values)\r\n});\r\n```\r\nActual Stuff \r\n```js\r\nexports.run = async (client, args, bot, msg, command) => {\r\n\tconst voicechk = bot.voiceCheck.get(msg.guild.id)\r\n\tconst voiceChannel = msg.member.voiceChannel;\r\n\tconst checkerBuild = {voiceChannel: voiceChannel}\r\n\tif (voicechk) return msg.channel.send('Teitoku-san, I am currently Playing a Voice Box. **Wait for it to end before invoking another one** Ufufu♪');\r\n\t\tif (!voiceChannel)\r\n\t\t\treturn msg.channel.send('You are **not in the Voice Channel** Teitoku ~');\r\n\t\tbot.voiceCheck.set(msg.guild.id, checkerBuild);\r\n\t\tvoiceChannel.join().then(voiceConnected => {\r\n\t\t    let voiceBoxPlay = voiceConnected.playStream('http://kure.kancollewiki.net/images/0/01/Kashima-Construction.mp3', {seek: 0});\r\n\t\t    voiceBoxPlay.once('start', () => {\r\n        \t    voiceConnected.player.streamingData.pausedTime = 0;\r\n        \t    voiceConnected.player.streamingData.timestamp = 0;\r\n            });\r\n\t\t\tvoiceBoxPlay.setVolumeLogarithmic(5 / 10);\r\n\t        voiceBoxPlay.once('end', async () => {\r\n\t        try {\r\n\t            await voiceChannel.leave()\r\n\t            bot.voiceCheck.delete(msg.guild.id);\r\n\t        } catch (err) {\r\n\t        console.error(error)\r\n\t        }\r\n\t    });\r\n\t}).catch(err => {\r\n\tconsole.error(err)\r\n\t});\r\n}\r\n```\r\n\r\n**Further details:**\r\n\r\n- discord.js version: 11.3-dev\r\n- node.js version: 8.11.0\r\n- Operating system: Ubuntu 16.04 LTS\r\n- Priority this issue should have – please be realistic and elaborate if possible: Medium, because I'm not sure whether this is a isolated case or not.\r\n\r\n<!--\r\nIf either of these applies to you, please check the respective checkbox: [ ] becomes [x].\r\nYou don't have to modify the text to suit your particular situation, if you want to\r\nelaborate please do so in the description.\r\nWhile it's not a requirement to test your issue on the master branch, it would make fixing\r\nthe problem a lot easier for us, so please do it if possible.\r\n-->\r\n- [ ] I found this issue while running code on a __user account__\r\n- [ ] I have also tested the issue on latest master, commit hash:\r\n"},"comment":{"url":"https://api.github.com/repos/discordjs/discord.js/issues/comments/415935073","html_url":"https://github.com/discordjs/discord.js/issues/2578#issuecomment-415935073","issue_url":"https://api.github.com/repos/discordjs/discord.js/issues/2578","id":415935073,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTkzNTA3Mw==","user":{"login":"Deivu","id":36309350,"node_id":"MDQ6VXNlcjM2MzA5MzUw","avatar_url":"https://avatars1.githubusercontent.com/u/36309350?v=4","gravatar_id":"","url":"https://api.github.com/users/Deivu","html_url":"https://github.com/Deivu","followers_url":"https://api.github.com/users/Deivu/followers","following_url":"https://api.github.com/users/Deivu/following{/other_user}","gists_url":"https://api.github.com/users/Deivu/gists{/gist_id}","starred_url":"https://api.github.com/users/Deivu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Deivu/subscriptions","organizations_url":"https://api.github.com/users/Deivu/orgs","repos_url":"https://api.github.com/users/Deivu/repos","events_url":"https://api.github.com/users/Deivu/events{/privacy}","received_events_url":"https://api.github.com/users/Deivu/received_events","type":"User","site_admin":false},"created_at":"2018-08-25T04:31:38Z","updated_at":"2018-08-25T04:31:38Z","author_association":"NONE","body":"Update, this is still happening\r\n\r\nThe error happens still on when the bot tries to join the Voice Channel. I handle the errors correctly with try catch wrapped around them inside an async function. I also listen for the client.on error event so I think this is an issue with d.js itself. Also I noticed that the more this 'error' happens, the more voice connection cache it leaves and it doesn't get still deleted.\r\n\r\n```\r\nError [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])\r\n    at VoiceConnection.emit (events.js:171:17)\r\n    at VoiceWebSocket.ws.on.err (/root/KashimaProd/node_modules/discord.js/src/client/voice/VoiceConnection.js:387:32)\r\n    at VoiceWebSocket.emit (events.js:182:13)\r\n    at VoiceWebSocket.onError (/root/KashimaProd/node_modules/discord.js/src/client/voice/networking/VoiceWebSocket.js:149:10)\r\n    at WebSocket.onError (/root/KashimaProd/node_modules/ws/lib/event-target.js:128:16)\r\n    at WebSocket.emit (events.js:182:13)\r\n    at ClientRequest.req.on (/root/KashimaProd/node_modules/ws/lib/websocket.js:528:10)\r\n    at ClientRequest.emit (events.js:182:13)\r\n    at TLSSocket.socketErrorListener (_http_client.js:391:9)\r\n    at TLSSocket.emit (events.js:182:13)\r\n```\r\n\r\nCode:\r\n```js\r\n    try {\r\n        client.joinCheck.add(msg.guild.id);\r\n        await msg.member.voice.channel.join();\r\n        await m.edit('\\:white_check_mark: Teitoku ♪ **I am now in your Voice Channel**, you can now use the commands **play**, **playmoe** or **voicequote**. But Teitoku, **I will auto leave in 1 minute** if you did not use the Voice Functions.');\r\n        client.joinCheck.delete(msg.guild.id);\r\n    } catch (error) {\r\n        await m.edit(`\\:x: Teitoku, I looks like **I cannot join here.** More info: **${error}**. Please wait a bit and Try Again.`);\r\n    };\r\n```\r\n\r\n**Further details:**\r\n- discord.js version: Discord.js Master, Commit 'ab0ede0'\r\n- Node.js version: 10.9.0\r\n- Operating system: Ubuntu 16.04 LTS"}}
{"actor":{"display_login":"Deivu"}}