Koenie06 / Discord.js-Music

19 stars 13 forks source link

isPaused() ain't working. #20

Open ZenDiscordd opened 2 years ago

ZenDiscordd commented 2 years ago

const pause = music.isPaused({ interaction: inter }); if(pause) return inter.reply({ content: 'Song is already paused', ephemeral: true });

This is my code to check if a song is paused. But when i run the command it says song is already paused even if its not paused.

Koenie06 commented 2 years ago

That is weird, it works for me.. Maybe update the package?

ZenDiscordd commented 2 years ago

That is weird, it works for me.. Maybe update the package?

It isn't for me. I even tried the code u gave in this repo. Well the function returns true if Music is paused and false if not paused that's what I read in the NPM page. But even if not paused its returning true for me. `const music = require('@koenie06/discord.js-music'); const Discord = require("discord.js")

module.exports = { name: "play", run: async(bot, inter) => { const isConnected = await music.isConnected({ interaction: inter }); if(!isConnected) return inter.reply({ content: 'There are no songs playing', ephemeral: true });

    const isPaused = music.isPaused({
        interaction: inter
    });
    if(isPaused) return inter.reply({ content: 'The song is already paused', ephemeral: true });

    music.pause({
        interaction: inter
    });

    inter.reply({ content: `Paused the music` });
}

}` This is the current code.

KasperBosteels commented 2 years ago

hello there.

isPaused is an async function meaning it will return a promise first. you need to change const isPaused = music.isPaused({... to let isPaused = await music.isPaused({... this should fix your issue.

here is some more info on async operations. https://www.w3schools.com/js/js_async.asp