【发布时间】:2021-10-15 21:22:57
【问题描述】:
我在发送关于 guildMemberAdd 事件的私人消息时遇到问题。
代码如下:
bot.on('guildMemberAdd', member => {
member.send('Welcome to the server.');
});
这会导致这个错误:
(node:11760) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
at RequestHandler.execute (C:\Users\AckeeXZ\Desktop\BOT\californianetwork\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async RequestHandler.push (C:\Users\AckeeXZ\Desktop\BOT\californianetwork\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11760) 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:11760) [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.
【问题讨论】:
标签: javascript node.js discord discord.js bots