AudioPlayerStatus.Idle

the bot dose not do anything when it finish
40 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
! Alk
! AlkOP2y ago
v13.12 node 16.13.1 written inside play file in commands folder , idk if this will help wow, i think it worked it dose not
Jiron
Jiron2y ago
Try replacing AudioPlayerStatus.Idle with a simple "idle" string
! Alk
! AlkOP2y ago
i've found weird thing, i have many audios, i've tried 3, 2 of them works totally fine, but one of them, if the audio finished it will not respone to any thing this player.on(AudioPlayerStatus.Idle, and thisconnection.on(VoiceConnectionStatus.Disconnected, can the issue be because the audio itself
Jiron
Jiron2y ago
Depends. Are you 100% sure the audio has played entirely or has it maybe been cut off? or by any case, is the audio that fails the longest of the 3?
! Alk
! AlkOP2y ago
yes, its 64sec
Jiron
Jiron2y ago
and it hasnt cut off after 60 secs.. hm
! Alk
! AlkOP2y ago
it will play at least 61 sec, then the audio itself has no sound in last 2 or 3 sec. so idk even if
Jiron
Jiron2y ago
I see
! Alk
! AlkOP2y ago
has cut of connection.on(VoiceConnectionStatus.Disconnected, this should work if something happend
! Alk
! AlkOP2y ago
Jiron
Jiron2y ago
But the bot doesnt leave the vc though as this part makes it leave but it doesnt work line 169, connection.disconnect();
! Alk
! AlkOP2y ago
it should log this at least console.log("Disconnected ?")
Jiron
Jiron2y ago
only if it actually leaves the vc. Does it leave when you play the audio that doesnt seem to work?
! Alk
! AlkOP2y ago
"only if it actually leaves the vc." i didn't understand this : ) Does it leave when you play the audio that doesnt seem to work?, it dose not
Jiron
Jiron2y ago
but does it leave the channel when you play a working audio?
! Alk
! AlkOP2y ago
yes
Jiron
Jiron2y ago
I see I see
Jiron
Jiron2y ago
GitHub
VoiceConnection stuck in signalling state about a minute after crea...
Which package is this bug report for? voice Issue description I've noticed a bug that seems to affect also some other users (see #8482). All the VoiceConnection works as intended the first ...
! Alk
! AlkOP2y ago
show me
Jiron
Jiron2y ago
Adding
const networkStateChangeHandler = (oldNetworkState: any, newNetworkState: any) => {
const newUdp = Reflect.get(newNetworkState, 'udp');
clearInterval(newUdp?.keepAliveInterval);
}

voiceConnection.on('stateChange', (oldState, newState) => {
const oldNetworking = Reflect.get(oldState, 'networking');
const newNetworking = Reflect.get(newState, 'networking');

oldNetworking?.off('stateChange', networkStateChangeHandler);
newNetworking?.on('stateChange', networkStateChangeHandler);
});
const networkStateChangeHandler = (oldNetworkState: any, newNetworkState: any) => {
const newUdp = Reflect.get(newNetworkState, 'udp');
clearInterval(newUdp?.keepAliveInterval);
}

voiceConnection.on('stateChange', (oldState, newState) => {
const oldNetworking = Reflect.get(oldState, 'networking');
const newNetworking = Reflect.get(newState, 'networking');

oldNetworking?.off('stateChange', networkStateChangeHandler);
newNetworking?.on('stateChange', networkStateChangeHandler);
});
Fixes the issue of bot connections not working anymore after exactly one minute of no activity in your case it would be
connection.on('stateChange', (oldState, newState) => {
const oldNetworking = Reflect.get(oldState, 'networking');
const newNetworking = Reflect.get(newState, 'networking');

const networkStateChangeHandler = (oldNetworkState, newNetworkState) => {
const newUdp = Reflect.get(newNetworkState, 'udp');
clearInterval(newUdp?.keepAliveInterval);
}

oldNetworking?.off('stateChange', networkStateChangeHandler);
newNetworking?.on('stateChange', networkStateChangeHandler);
});
connection.on('stateChange', (oldState, newState) => {
const oldNetworking = Reflect.get(oldState, 'networking');
const newNetworking = Reflect.get(newState, 'networking');

const networkStateChangeHandler = (oldNetworkState, newNetworkState) => {
const newUdp = Reflect.get(newNetworkState, 'udp');
clearInterval(newUdp?.keepAliveInterval);
}

oldNetworking?.off('stateChange', networkStateChangeHandler);
newNetworking?.on('stateChange', networkStateChangeHandler);
});
since you called it "connection" like pretty much everyone has
! Alk
! AlkOP2y ago
what's Reflect
Jiron
Jiron2y ago
Its a namespace built into nodejs as far as I know
! Alk
! AlkOP2y ago
oh
Jiron
Jiron2y ago
is it saying that reflect is undefined?
! Alk
! AlkOP2y ago
no just my mind is saying testing
Jiron
Jiron2y ago
In case it bugs around/doesnt work. I just realized someone changed the code a bit: https://github.com/discordjs/discord.js/issues/9185#issuecomment-1459083216 But yeah I hope the other one already works
! Alk
! AlkOP2y ago
ty, it worked so if the duration is longer than a min, this issue will happen?
Jiron
Jiron2y ago
exactly, because of a recent update of discord This also goes for receiving audio from other people. The bot is in the vc but is technically disconnected
! Alk
! AlkOP2y ago
and this code will change the status to idle ? then this player.on(AudioPlayerStatus.Idle, () => { will work
Jiron
Jiron2y ago
It sends a udp packet to the api afaik, basically saying "Hey let me stay connected for longer" Like that the entire audio plays Not adding that will cause the audio to cut at exactly 1 minute and because of that, AudioPlayerStatus.Idle event is not fired
! Alk
! AlkOP2y ago
great thanks a lot
Jiron
Jiron2y ago
Np :)
! Alk
! AlkOP2y ago
i've one question for example i'm playing an audio now and i want to play new audio before the first one finish should i destroy the connection and then create a new one
if (connection) connection.destroy()
connection = joinVC(interaction.member.voice.channel);
if (connection) connection.destroy()
connection = joinVC(interaction.member.voice.channel);
or it's ok to keep it
Jiron
Jiron2y ago
Do you want the audio to overlap or do you want the next audio to start playing right after the first one finished?
! Alk
! AlkOP2y ago
overlap no i mean stop the first and play the sec dose this mean "overlap "?
Jiron
Jiron2y ago
Nono overlap is when both audios play at the same time for a little time Well in that case, no I would keep the connection and then when AudioPlayerStatus.Idle is fired, you can just create a new player and play it like you did here Maybe creating a function so you dont repeat the code would be perfect here then haha
! Alk
! AlkOP2y ago
i think u did not understand me i mean when i play an audio and there's already a connection should i use it or destroy it and create new
Jiron
Jiron2y ago
Like for the second audio? I would just use it The same one
! Alk
! AlkOP2y ago
<:4KR_53:1036763198801592480> i think i had an issue before if i played an audio then played other when with the same connection and enabled "repeat" for only the second audio, both audios will be repeated ty anyway how to end the post
Want results from more Discord servers?
Add your server