无法让YTDL-core与discord.js一起使用

时间:2017-10-21 17:01:14

标签: javascript node.js bots discord discord.js

代码:https://github.com/Zentrik/DiscordBot/blob/master/Bot.js

我得到错误:

 server.queue.push(args[1]);
                  ^

TypeError: Cannot read property 'queue' of undefined
    at Client.<anonymous> (/home/ubuntu/discordbot/bot.js:133:19)
    at emitOne (events.js:115:13)
    at Client.emit (events.js:210:7)
    at MessageCreateHandler.handle (/home/ubuntu/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/home/ubuntu/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (/home/ubuntu/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:330:35)
    at WebSocketConnection.onMessage (/home/ubuntu/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:293:17)
    at WebSocket.onMessage (/home/ubuntu/node_modules/ws/lib/EventTarget.js:99:16)
    at emitOne (events.js:115:13)
    at WebSocket.emit (events.js:210:7)

或者:

(node:8565) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'push' of undefined
(node:8565) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我从这里得到了这段代码:https://www.youtube.com/watch?v=z4S2qqX7YvA

我很确定代码是一样的。

机器人加入语音频道,并有权加入和发言。

我是javascript的新手所以我不知道任何帮助将会有什么问题

编辑:有一个拼写错误,我修复了它,但现在音频在启动后立即完成,没有声音产生。

服务器[message.guild.id]为[object Object]

server.queue [0]是相同的网址,但后来在网址末尾添加了“未定义”。

server.dispatcher也是[object Object]

1 个答案:

答案 0 :(得分:0)

这不是代码的问题,因为它可以在其他机器上运行,感谢您的帮助。 FFMPEG不适用于更新的debian系统,而是执行sudo apt-get install libav-tools -y