我在获取命令以等待机器人在踢用户之前通知用户时遇到了一些问题,我设置了一个等待 5 秒的功能,但它在 5 秒结束前就开始了以下是我的代码和错误。>
它说的“等待”没有定义,但我看了 here 并使用了其中之一,稍作修改。
我还有另一个不太重要的问题,我将如何做到让运行 !kickme 命令的人登录到 .txt 文件或类似文件?
编辑:我想我澄清一下。是的,我试图踢出发送 !kickme 命令的用户。它意味着一个完全无用的命令,让人们乱来。它应该向他们发送带有服务器邀请的 dm(以便他们可以重新加入)然后踢他们。
到目前为止,它还没有将 dm 发送给他们,只是在踢他们
const Discord = require('discord.js')
module.exports.run = async (bot, message, args) => {
const user = message.author
const member = message.guild.member(user);
message.author.send(`Here is an invite so you can join back! https://discord.gg/FBXSduget2 `)
const timew = async (bot, message, args) => {
wait(5000);
console.log("Waited 5s");
wait(5000);
console.log("Waited an additional 5s");
};
timew();
if (member) {
member
.kick('User was kicked')
.then(() => {
console.log(`${user.tag} Kicked themself`);
message.channel.send(`${user.tag} kicked themself`)
})
.catch(err => {
message.reply('Unable');
console.error(err);
});
}
}
module.exports.help = {
name: "kickme"
}
(node:13216) UnhandledPromiseRejectionWarning: ReferenceError: wait is not defined
at timew (C:\Users\8fwbu\Desktop\CodeTProj\-Tux V2\commands\kickme.js:12:9)
at Object.module.exports.run (C:\Users\8fwbu\Desktop\CodeTProj\-Tux V2\commands\kickme.js:19:7)
at Client.<anonymous> (C:\Users\8fwbu\Desktop\CodeTProj\-Tux V2\main.js:42:31)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\8fwbu\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\8fwbu\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\8fwbu\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
at WebSocketShard.onPacket (C:\Users\8fwbu\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (C:\Users\8fwbu\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (C:\Users\8fwbu\node_modules\ws\lib\event-target.js:132:16)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13216) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:13216) [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.
(node:13216) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
at RequestHandler.execute (C:\Users\8fwbu\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async RequestHandler.push (C:\Users\8fwbu\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
(node:13216) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Unicorn-Barf#9255 Kicked themself
答案 0 :(得分:0)
您的错误来自使用 FROM (SELECT customer.customer_id, customer_name, address_line_1, city, state_province, count(order_header.customer_id) AS ordercount
FROM customer
LEFT JOIN order_header ON customer.customer_id = order_header.customer_id
GROUP BY customer.customer_id) AS vipTable
,因为它没有定义。
您可以在发送消息时使用 wait(5000);
以确保它们被发送。
await