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

The function dispatcher.pause() and dispatcher.resume() only works on a second switch #5300

Closed
SrRapero720 opened this issue Feb 7, 2021 · 9 comments · Fixed by #5402
Closed

Comments

@SrRapero720
Copy link

SrRapero720 commented Feb 7, 2021

When i stop a song with .pause() it stops (as it should), but when i use .resume() the song does not resume playing and does not do so by repeating the function one more time.

for the song to resume it must be "paused" again and then "resumed".
the process is repeated in the same way once the song is resumed (don't gives me errors).

MORE DETAILS (AND TIMINGS): https://youtu.be/OsdpQEdE1QE

import Discord from 'discord.js';
import ytdl from 'ytdl-core';
import dotenv from 'dotenv';
import SrConsole from "sr-console";
import path from "path";

const __dirname = path.resolve('..')

const console = new SrConsole({
    dirname: __dirname,
    filter: [
        "[REDACTED]"
    ]
});

dotenv.config();

const client: Discord.Client = new Discord.Client();
const menu: Array<Discord.StreamDispatcher | undefined> = new Array();

client.on('ready', () => {
    console.log('the server is ready... bot started')
});

client.on('error', (dat) => console.err(dat));
client.on('warn', (dat) => console.warn(dat));
client.on('debug', (dat) => console.send(dat));

client.on('message', async (msg) => {
    if (msg.content === "--demo-play") {
        const voiceIP = await msg.member?.voice.channel?.join();
        menu.push(voiceIP?.play(ytdl('https://www.youtube.com/watch?v=GYtBoxGB6Wo')));
        console.debug('Music started to play');
    }

    if (msg.content === "--pause") {
        menu[0]?.pause();
        console.debug('Music Paused');
        console.debug('Paused status:', menu[0]?.paused);
    }

    if (msg.content === "--resume") {
        menu[0]?.resume();
        console.debug('Music resume');
        console.debug('Paused status:', menu[0]?.paused);
    }
});

client.login(process.env.TOKEN);

export default client; //unnecesary

Further details:

  • discord.js version: 12.5.1
  • Node.js version: 15.8.0
  • Operating system: Windows 10
  • Typescript version: 4.1.3
  • Priority this issue should have: this does not affect the general operation of the bot and music playback. just to control the music... which is important but not essential

Relevant client options:

  • none
@BocajBot
Copy link

BocajBot commented Feb 8, 2021

I had a similar issue. The issue was fixed after uninstalling node 15.8 and installing 14.15.4

@GeorgeH005
Copy link

GeorgeH005 commented Feb 10, 2021

Same issue fixed by installing latest lts node 14.x

@BearTS
Copy link

BearTS commented Feb 12, 2021

Developers should fix it for node v15.x

@JaxkDev
Copy link

JaxkDev commented Mar 20, 2021

Having this exact issue on node v15.11.0 but the pause/resume x2 doesn't work as a 'hacky fix'

@MrPropre
Copy link

MrPropre commented Apr 3, 2021

The "hacky fix" does not work when pausing the song with silent option.

- dispatcher.pause(true)
+ dispatcher.pause()

@jbelford
Copy link

I also found this happening for LTS v14.17.0

Fixed by using v14.16

@Hazmi35
Copy link

Hazmi35 commented May 19, 2021

Could reproduce with Node.js version 14.17.0 or above

@slack2450
Copy link

Can confirm is occuring on v14.17.0 Downgrading to v14.16.1 resolved this for me

@amishshah
Copy link
Member

Hi there,

We're working on a new implementation of Discord's Voice API that has better playback quality and is more reliable than what we currently support in Discord.js v12 - check it out at https://github.com/discordjs/voice!

The new library solves many of the issues that users are facing, and as part of this, we're dropping built-in support for voice in our next major release. We have a PR (#5402) that adds native support for our new voice library - once this PR is merged, this issue will be closed.

You can still use our new voice library before that PR lands - just take a look at our music bot example to see how to get started upgrading your voice code. By using the boilerplate music player in the example, you can make it even easier to upgrade your code.

Note that the PR above only reduces some of the boilerplate code you'd otherwise have to write - you do not have to wait for the PR to be merged to start using the new voice library.


If you have any questions about this, feel free to:

  • Make an issue if you have found a bug in the new voice library
  • Use GitHub Discussions or join our Discord server (we have a new channel, #djs-new-voice, specifically for this!) to ask general questions about the library, give feedback on the library, and get support with upgrading to it

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.