因此,即使用户做出了反应,我的机器人也不会发送消息,然后出现错误...顺便说一句,由于承诺拒绝错误,我在代码中放置了很多.catch错误
client.on("guildMemberAdd", member => {
try {
member.send(`Hello ${member}, welcome to the PotatoHost Server!
I want to help you and so my question is: Do you want to buy a server or do you need more informations first? \n
A: I want to buy a server
B: I need more informations first \n
Please react to this message with A or B.`)
.catch(err => console.log('err1'))
.then(function (message) {
message.react("?")
.catch(err => console.log(err));
message.react("?")
.catch(err => console.log(err));
message.awaitReactions((reaction, user) => user.id == message.author.id && (reaction.emoji.name == '?' || reaction.emoji.name == '?'),
{ max: 1})
.catch(err => console.log(err))
.then(collected => {
if (collected.first().emoji.name == '?') {
message.send('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.')
.catch(err => console.log(err));
}
else
message.send('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.')
.catch(err => console.log(err));
})
});
}catch (err) {
console.log(err)
}
})
以下是我不知道如何解决的错误:
(node:31944) UnhandledPromiseRejectionWarning: TypeError: message.send is not a function
at C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\index.js:27:33
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:31944) 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:31944) [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 :(得分:4)
没有message.send()
这样的东西,您需要将其替换为message.channel.send()
您一直在询问有关此类小问题的信息,您需要阅读文档:https://discord.js.org/#/docs/main/stable/general/welcome