UnhandledPromiseRejectionWarning и многое другое, но я не знаю почему - PullRequest
0 голосов
/ 16 апреля 2020

Поэтому я поместил блок message.awaitReaction в блок .then, чтобы я не получил сообщение «ошибка не определена», и теперь ошибок больше, чем раньше, и бот даже не реагирует со вторым смайликом. на его сообщение. Я понимаю, почему я не понимаю, как это связано с функцией asyn c или функцией catch, хотя она у меня есть. Кстати, я новичок, и я надеюсь, что мое форматирование понятно

client.on("guildMemberAdd", async member => {
        try {
            await 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.`)
            .then(function (message) {
                message.react("?")
                message.react("?")     
                message.awaitReactions((reaction, user) => user.id == message.author.id && (reaction.emoji.name == '?' || reaction.emoji.name == '?'),
                    { max: 1}).then(collected => {
                        if (collected.first().emoji.name == '?') {
                            message.reply('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
                            client.destroy();
                        }
                        else
                            message.reply('Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.');
                    })
            });
        } 
        catch (err) {
            console.log(err)
        }
    })

Ошибка:

    (node:17020) UnhandledPromiseRejectionWarning: DiscordjsError: Request to use token, but token was unavailable to the client.
        at RequestHandler.execute (C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\node_modules\discord.js\src\rest\RequestHandler.js:107:21)
        at RequestHandler.push (C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\node_modules\discord.js\src\rest\RequestHandler.js:41:19)
        at C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\node_modules\discord.js\src\rest\RESTManager.js:41:10
        at new Promise (<anonymous>)
        at RESTManager.push (C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\node_modules\discord.js\src\rest\RESTManager.js:39:12)
        at RESTManager.request (C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\node_modules\discord.js\src\rest\RESTManager.js:60:17)
        at Proxy.<anonymous> (C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\node_modules\discord.js\src\rest\APIRouter.js:30:19)    at DMChannel.send (C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:174:8)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
...