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

SUCCESS: Bot stops playing after around 1 minute #97

Open
Henrik-Henkel opened this issue Mar 1, 2023 · 19 comments
Open

SUCCESS: Bot stops playing after around 1 minute #97

Henrik-Henkel opened this issue Mar 1, 2023 · 19 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation question Further information is requested

Comments

@Henrik-Henkel
Copy link

The bot stops playing after around 1 minute of playback... No error in the console.

Any idea what could be causing this?

@y0zhyck
Copy link

y0zhyck commented Mar 2, 2023

I have the same thing going on

@y0zhyck
Copy link

y0zhyck commented Mar 2, 2023

How to Fix?

@Henrik-Henkel
Copy link
Author

Discord has made an announcement on the Discord Developers server in regards to the change that broke most musicbots.

image

@Henrik-Henkel
Copy link
Author

Whoops. Didn't mean to close the issue... Can we get an update for the bot?

@Henrik-Henkel Henrik-Henkel reopened this Mar 2, 2023
@y0zhyck
Copy link

y0zhyck commented Mar 2, 2023

Discord has made an announcement on the Discord Developers server in regards to the change that broke most musicbots.

image

Okay, that's all, but how to fix the situation or wait for the expected fifteen years?

@Henrik-Henkel
Copy link
Author

I think only the author can provide us with a fix for that

@MiniGrief
Copy link

MiniGrief commented Mar 2, 2023

Modified from this: discordjs/discord.js#9185 (comment)

This is an issue inside of discord.js related to the screenshot above. You can add a patch to distube (a node module used in this bot) which seems to fix the issue.

MusicBot/node_modules/distube/dist/index.js
Above this around line 754
this.connection.on(import_voice.VoiceConnectionStatus.Disconnected, (_, newState) => {
Add this:
this.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);
});

@y0zhyck
Copy link

y0zhyck commented Mar 2, 2023

like this?
image

@MiniGrief
Copy link

like this? image

Above that, not below.

@y0zhyck
Copy link

y0zhyck commented Mar 3, 2023

like this? image

Above that, not below.

It worked, wow!!!!!

Repository owner locked and limited conversation to collaborators Mar 4, 2023
@umutxyp umutxyp changed the title Bot stops playing after around 1 minute SUCCESS: Bot stops playing after around 1 minute Mar 4, 2023
@umutxyp umutxyp added bug Something isn't working documentation Improvements or additions to documentation question Further information is requested labels Mar 4, 2023
@umutxyp umutxyp pinned this issue Mar 4, 2023
Repository owner unlocked this conversation Mar 4, 2023
@MadTiago
Copy link

MadTiago commented Mar 8, 2023

Modified from this: discordjs/discord.js#9185 (comment)

This is an issue inside of discord.js related to the screenshot above. You can add a patch to distube (a node module used in this bot) which seems to fix the issue.

MusicBot/node_modules/distube/dist/index.js Above this around line 754 this.connection.on(import_voice.VoiceConnectionStatus.Disconnected, (_, newState) => { Add this: this.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); });

That comment has been updated according to discordjs/discord.js#9185 (comment)
So in this case, you should use:

const networkStateChangeHandler = (oldNetworkState, newNetworkState) => {
    const newUdp = Reflect.get(newNetworkState, 'udp');
    clearInterval(newUdp?.keepAliveInterval);
}
this.connection.on('stateChange', (oldState, newState) => {
    Reflect.get(oldState, 'networking')?.off('stateChange', networkStateChangeHandler);
    Reflect.get(newState, 'networking')?.on('stateChange', networkStateChangeHandler);
});

@Ren0X1
Copy link

Ren0X1 commented Mar 23, 2023

any update?

@MiniGrief
Copy link

any update?

I think the issue in discordjs is actually fixed now so you can just update it using npm i @discordjs/voice@latest and it should work.

@Hoshimikan6490
Copy link
Contributor

Modified from this: discordjs/discord.js#9185 (comment)

This is an issue inside of discord.js related to the screenshot above. You can add a patch to distube (a node module used in this bot) which seems to fix the issue.

MusicBot/node_modules/distube/dist/index.js Above this around line 754 this.connection.on(import_voice.VoiceConnectionStatus.Disconnected, (_, newState) => { Add this: this.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); });

I changed code like this and used npm i @discordjs/voice@latest.
However, I saw this issue again.
What I should do?

@Hoshimikan6490
Copy link
Contributor

I was fixed this problem.
I seted like this.

client.config = config;
client.player = new DisTube(client, {
  leaveOnStop: config.opt.voiceConfig.leaveOnStop,
  leaveOnFinish: config.opt.voiceConfig.leaveOnFinish,
  leaveOnEmpty: config.opt.voiceConfig.leaveOnEmpty.status,
  emitNewSongOnly: true,
  emitAddSongWhenCreatingQueue: false,
  emitAddListWhenCreatingQueue: false,
  plugins: [
    new SpotifyPlugin(),
    new SoundCloudPlugin(),
    new YtDlpPlugin(),
    new DeezerPlugin(),
  ],
});

However, this change is for my program. So, it may not be a good change for programs in this repository.

@Saadalayed
Copy link

Saadalayed commented Jun 11, 2023

How do I fix it ?

Screenshot 2023-06-11 211355

@Hoshimikan6490
Copy link
Contributor

After running npm i, run node index.js.
Does that fix it?

@harshitkamboj
Copy link

run this command

npm i @discordjs/voice@latest

@Lucfost
Copy link

Lucfost commented Aug 11, 2023

thx it worked

@umutxyp umutxyp unpinned this issue Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

11 participants