【问题标题】:My discord music bot played music just fine and 1 day later, without any changes, it gives me an error我的不和谐音乐机器人播放音乐很好,1 天后,没有任何变化,它给了我一个错误
【发布时间】:2020-01-13 12:45:29
【问题描述】:

我按照 youtube 编码教程对音乐机器人进行编码,然后逐步升级命令,我亲自测试了所有内容,直到它完美运行。 1 天后,我在尝试播放音乐时遇到错误,我不知道发生了什么。

我尝试在我的代码中删除一些可能是问题的东西,最后它们都不是真正的问题

const YTDL = require('ytdl-core')

function play(connection, message)
    {
        var server = servers[message.guild.id]

        server.dispatcher = connection.playStream(YTDL(server.queue[0], {filter: "audioonly"}))

        server.dispatcher.on("end", function() {
            if(server.queue[0]) 
            {
                play(connection, message)




                const args = server.queue[0]
                YTDL.getInfo(args, function(err, info) {
                    const title = info.title
                    message.channel.send(`:musical_note: **${title}** is now playing!`)
                })
                server.queue.shift()
            }
            else 
            {
                connection.disconnect()
                message.channel.send(":warning: There are no more songs in the queue!")
            }
        })
    }



class playCommand extends commando.Command

    {   
        constructor(client)
        {
            super(client, {
                name: 'play',
                group: 'simple',
                memberName: 'play',
                description: 'idfl'
            })
        }

        async run(message, args)
        {
            if(!args[0])
            {
                message.channel.send("Please provide a link")
                return;
            }
            if(!message.member.voiceChannel)
            {
                message.channel.send("You must be in a voice channel")
                return;
            }
            if (message.content.includes("http://") || message.content.includes("https://")) {
                if (message.content.includes("youtube") || message.content.includes("youtu.be")) {

            if(!servers[message.guild.id]) servers[message.guild.id] = {queue: []}
            var server = servers[message.guild.id]
            server.queue.push(args)

            if(!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection) {
                play(connection, message)
                const args = message.content.split(" ").slice(1);
                YTDL.getInfo(args.join(" "), function(err, info) {
                    const title = info.title
                message.channel.send(`:musical_note: **${title}** is now playing!`)
                    })
                    server.queue.shift()
                })

            }
            else
            {
                message.reply("Only youtube links!")
            }
        }
        else
        {
            message.reply("Only youtube links!")
        }
    }
}

module.exports = playCommand;

应该发生的事情是:机器人播放音乐并发送一条包含他正在播放的歌曲的消息,而这在 1 天前运行良好。这是我遇到的错误。

C:\Users\Nume\Desktop\Bot\node_modules\opusscript\build\opusscript_native_wasm.js:8
var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=function(status,toThrow){throw toThrow};Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locate

Error: This video is unavailable
    at C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\info.js:255:16
    at Object.exports.<computed> [as getBasicInfo] (C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\info.js:367:7)
    at exports.getFullInfo (C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\info.js:211:18)
    at Function.exports.<computed> [as getInfo] (C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\info.js:369:7)
    at ytdl (C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\index.js:17:8)
    at play (C:\Users\Nume\Desktop\Bot\commands\simple\play.js:8:51)
    at StreamDispatcher.<anonymous> (C:\Users\Nume\Desktop\Bot\commands\simple\play.js:13:17)
    at StreamDispatcher.emit (events.js:209:13)
    at StreamDispatcher.destroy (C:\Users\Nume\Desktop\Bot\node_modules\discord.js\src\client\voice\dispatcher\StreamDispatcher.js:294:10)
    at AudioPlayer.destroyCurrentStream (C:\Users\Nume\Desktop\Bot\node_modules\discord.js\src\client\voice\player\AudioPlayer.js:77:18)
Emitted 'error' event on PassThrough instance at:
    at C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\index.js:19:14
    at C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\info.js:370:25
    at C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\info.js:255:7
    at Object.exports.<computed> [as getBasicInfo] (C:\Users\Nume\Desktop\Bot\node_modules\ytdl-core\lib\info.js:367:7)
    [... lines matching original stack trace ...]
    at StreamDispatcher.emit (events.js:209:13)

【问题讨论】:

标签: javascript discord discord.js


【解决方案1】:

更新了 ytdl-core,之后它工作得非常好

【讨论】:

    猜你喜欢
    • 2021-05-05
    • 2020-12-19
    • 2019-04-04
    • 1970-01-01
    • 2020-11-16
    • 2021-10-25
    • 2020-03-16
    • 2020-06-20
    • 1970-01-01
    相关资源
    最近更新 更多