错误:
(node:66444) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'queue' of undefined
at Play (C:\Users\InfoN9INSQ\Desktop\AllYouNeedBot\index.js:187:58)
at Client.client.on (C:\Users\InfoN9INSQ\Desktop\AllYouNeedBot\index.js:77:9)
at Client.emit (events.js:182:13)
at MessageCreateHandler.handle (C:\Users\InfoN9INSQ\Desktop\AllYouNeedBot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\InfoN9INSQ\Desktop\AllYouNeedBot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\InfoN9INSQ\Desktop\AllYouNeedBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\InfoN9INSQ\Desktop\AllYouNeedBot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\InfoN9INSQ\Desktop\AllYouNeedBot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver._receiver.onmessage (C:\Users\InfoN9INSQ\Desktop\AllYouNeedBot\node_modules\ws\lib\websocket.js:137:47)
(node:66444) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:66444) [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.
导致错误的函数:
function Play(connection, message, server, servers) {
server.dispatcher = connection.playStream(YTDL(servers.queue[0], {
filter: "audioonly"
}));
server.queue.shift();
server.dispatcher.on("end", function() {
if (server.queue[0]) {
Play(connection, message);
} else {
connection.disconnect();
}
});
}
我需要帮助才能使其正常工作!我还有另一个机器人,其代码几乎像这样,并且运行良好!目前它是一个具有很多功能的机器人,我正在尝试添加音乐功能!
可以找到整个代码here。