我尝试使用asyncio.sleep(60);
,但不起作用。在机器不离线的情况下,有什么方法可以让事情暂停一分钟?
if (cmd === `${prefix}countdown`) {
console.log('cmd Countdown found');
if (message.member.roles.find("name", "Queue Master")) {
let durationString = args.toString();
var durationInt = parseInt(durationString);
console.log('starting cd process');
message.channel.send('Scrim starting in ' + durationString + ' mins');
for (; durationInt > 0; durationInt--) {
asyncio.sleep(60);
durationString = durationInt.toString();
message.channel.send('Scrim starting in ' + durationString + ' mins');
}
if (durationInt === 0) {
message.channel.send('The host will join the Countdown channel and give you info about the scrim!');
}
}
}
这是错误:
(node:4) DeprecationWarning: Collection#find: pass a function instead
(node:4) UnhandledPromiseRejectionWarning: ReferenceError: asyncio is not defined
at Client.bot.on (/app/index.js:100:17)
at Client.emit (events.js:197:13)
at MessageCreateHandler.handle (/app/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/app/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:197:13)
at Receiver._receiver.onmessage (/app/node_modules/ws/lib/websocket.js:137:47)
at Receiver.dataMessage (/app/node_modules/ws/lib/receiver.js:409:14)
(node:4) 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:4) [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.
答案 0 :(得分:1)
该错误说明了问题所在:
asyncio is not defined
asyncio
似乎是一个Python库,因此它不会在JavaScript中存在。