简体   繁体   中英

Discord Bot doesnt send message when user reacts

So my bot doesn't send a message when the user reacts even though he should, and then there are the errors... btw I put so many.catch error in the code because of the promise rejection error

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)
    }
})

Here are the errors that i dont know how to fix:

(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.

There is no such thing as message.send() you need to replace that with message.channel.send()

You have been asking questions about little things like this for a bit, you need to read the documentation: https://discord.js.org/#/docs/main/stable/general/welcome

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM