Please describe the problem you are having in as much detail as possible:
Discord Bot is leaving voice channel unexpectedly.
I tried to check if the connection is alive and if not rejoin but didn't work
Include a reproducible code sample here, if possible:
let voiceChannelGet = bot.channels.get(notification.voiceChannel);
// Check if bot is in voice channel
const guild = bot.guilds.get(voiceChannelGet.guild.id);
if (!guild.voiceConnection) {
voiceChannelGet.leave();
await sleep(1000);
}
let voiceChannel = await bot.channels.get(notification.voiceChannel).join();
if (!voiceChannel) {
return;
}
let dispatcher = undefined;
if (notification.type === "boss") {
dispatcher = voiceChannel.play(
path.join(resPath, notification.voice + ".mp3")
);
}
Further details:
Could you include a log from client.on('debug', console.log) so there is more information to work with?
This could be related when the bot is playing music, then the ws failed to resume the session so it Identifies new.
I tried to log debug but I'm not able to capture it since it gives me so many logs. ðŸ˜
the error log is
ErrorEvent {
target:
WebSocket {
domain: null,
_events:
[Object: null prototype] {
open: [Function],
message: [Function],
close: [Function],
error: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
readyState: 2,
protocol: '',
_binaryType: 'nodebuffer',
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_closeCode: 1006,
_extensions: {},
_receiver: null,
_sender: null,
_socket: null,
_isServer: false,
_redirects: 0,
url: 'wss://undefined/?v=4&encoding=json',
_req: null },
type: 'error',
message: 'getaddrinfo ENOTFOUND undefined undefined:443',
error:
{ Error: getaddrinfo ENOTFOUND undefined undefined:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'undefined',
host: 'undefined',
port: 443 },
domainEmitter:
VoiceConnection {
domain:
Domain {
domain: null,
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
members: [] },
_events:
[Object: null prototype] {
closing: [Array],
debug: [Function],
failed: [Function],
disconnect: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
voiceManager:
ClientVoiceManager { client: [Client], connections: [Collection], broadcasts: [] },
channel:
VoiceChannel {
type: 'voice',
deleted: false,
id: '522022381078970368',
name: '蹂댄깘?뚮??ㅲ솯',
rawPosition: 0,
parentID: null,
permissionOverwrites: Collection [Map] {},
bitrate: 64000,
userLimit: 0,
guild: [Guild] },
status: 0,
speaking: Speaking { bitfield: 0 },
authentication:
{ ssrc: 1496,
port: 51016,
modes: [Array],
ip: '103.126.138.86',
mode: 'xsalsa20_poly1305_lite',
video_codec: 'VP8',
secret_key: [Uint8Array],
media_session_id: 'b3f0e62b0e26936988ae9413f5e4d29f',
audio_codec: 'opus' },
player:
AudioPlayer {
domain: [Domain],
_events: [Object],
_eventsCount: 2,
_maxListeners: undefined,
dispatcher: null,
streamingData: [Object],
voiceConnection: [Circular] },
ssrcMap:
Map {
1421 => '403579720689778699',
723 => '535743089118281730',
1499 => '348318797402472458',
1502 => '338286366427316226',
1508 => '171994868732788736',
1511 => '205331693228392449',
1514 => '335667845008719873',
1517 => '247239019224629253',
1520 => '341496297930358785',
1523 => '377757386699702272',
1526 => '342286857456975872',
1529 => '339727386696351754',
1532 => '205331693228392449',
1535 => '365509931828510726',
1538 => '346898613869477902' },
_speaking: Map {},
sockets: { ws: [VoiceWebSocket], udp: [VoiceConnectionUDPClient] },
receiver:
VoiceReceiver {
domain: [Domain],
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
connection: [Circular],
packets: [PacketHandler] },
connectTimeout:
Timeout {
_called: false,
_idleTimeout: -1,
_idlePrev: null,
_idleNext: null,
_idleStart: 43621389,
_onTimeout: null,
_timerArgs: undefined,
_repeat: null,
_destroyed: true,
domain: [Domain],
[Symbol(unrefed)]: false,
[Symbol(asyncId)]: 10245209,
[Symbol(triggerId)]: 10245183 } },
domain:
Domain {
domain: null,
_events:
[Object: null prototype] {
removeListener: [Function: updateExceptionCapture],
newListener: [Function: updateExceptionCapture],
error: [Function] },
_eventsCount: 3,
_maxListeners: undefined,
members: [] },
domainThrown: false }
url: 'wss://undefined/?v=4&encoding=json',
_req: null },
type: 'error',
message: 'getaddrinfo ENOTFOUND undefined undefined:443',
error:
{ Error: getaddrinfo ENOTFOUND undefined undefined:443
eh
Yeah I changed DNS to google's and it doesn't have change
Having the same problem here
I've been able to reproduce this myself, will look at fixing it soon, currently a bit busy!
Thank you :)
This fix should allow the bot to reconnect for now without errors, but streams might not reconnect properly. I'll take another look at the reconnect logic when I'm free to try and make it more robust!
@amishshah the problem now is bot doesn't say anything :(
only the reenter sound is what I get
it works perfectly on when running on mac but when on windows the problem happens
same on ubuntu 18, node v10
@ktjd123 ok, could you move to #2978 to discuss this new issue? It seems like a more relevant issue where we can keep track of it
Okay :)