Search code examples
javascriptnpmdiscord.jsmp3opus

Trying to play an audio file in Disocrd.js


i am able to get my bot in vc just fine but when i try to play audio i get alot of error saying im missing the fallowing modules [@discordjs/opus, node-opus, opusscript] i installed them but idk what requires it [const ??? = require('@discordjs/opus');] here is the code and error: https://hastebin.com/nibegohowo.diff

    run: async (bot, message, args) => {
        var VC = message.member.voice.channel;
        if (!VC)
            return message.reply("MESSAGE IF NOT IN A VOICE CHANNEL")
        VC.join()
        .then(connection => {
            const dispatcher = connection.play('../../Database/Music/Sheep sounds.mp3');
            dispatcher.on("end", end => {VC.leave()});
        })
        .catch(console.error);

    }

Solution

  • You don't need to add a require('@discordjs/opus') to your code, but it looks like opusscript is missing on your computer. You can install it like this:

    npm i opusscript
    

    But I hear discord prefers node-opus

    npm i node-opus