等待消息中的消息反应等待反应,错误(message.react不是函数)

时间:2020-05-15 08:58:06

标签: javascript async-await bots discord.js

为什么它说:UnhandledPromiseRejectionWarning:TypeError:message.react可能不是一个函数,因为它已经在等待消息中了-> if(response emoji = C)but idk我会得到的改变

} else if (mainEmbedEmoji == "?") {
                // call the lord EmojiMessageMan1 to handle reactions
                async function emojiMessageMan1(message, validReactions) {

                    // validReactions = ["one", "two"]
                    for (const reaction1 of validReactions) await message.react(reaction1);

                    // filter
                    const filter1 = (reaction, user) => validReactions.includes(reaction.emoji.name) && (!user.bot)

                    // returns emoji the user reacted with
                    return message
                        .awaitReactions(filter1, {
                            max: 1,
                        })
                        .then(collected => collected.first() && collected.first().emoji.name);
                }

                const bigC = new MessageEmbed()
                    .setColor('0x0099ff')
                    .setTitle("Premium Minecraft Servers")
                    .setDescription(`*Link:* https://cloudx.host/cart.php?gid=1\n\nYou want to host a Minecraft Java Edition Server? No problem, with our High-End specifications will your Server be online 24/7 and you can enjoy Minecraft with your friends without having to worry about connection!\n\n**Options/Prices:**`)
                    .addField(`**RAM Options:**`, "*Please choose how much RAM your Server should have:*\n:one:: 1 GB RAM\n:two:: 2 GB RAM\n:three:: 3 GB RAM\n:four:: 4 GB RAM\n:six:: 6 GB RAM\n:eight:: 8 GB RAM\n:keycap_ten:: 10 GB RAM\n\nPlease react to this message with :one:, :two:, :three:, :four:, :six:, :eight: or :keycap_ten:")


                // sends bigC and await for reactions

                let mainEmbedMsg1 = "";
                    await message.channel.send(bigC).then((message) => {
                        mainEmbedMsg1 = message
                    })
                let mainEmbedEmoji1 = await emojiMessageMan1(bigC, ['1⃣', '2⃣', '3⃣', '4⃣', '6⃣', '8⃣', '?'])

1 个答案:

答案 0 :(得分:1)

emojiMessageMan1函数调用中,您作为第一个参数bigC(即MessageEmbed)传递。

但是您实际上在反应处理程序中等待Message

因此,您必须传递mainEmbedMsg1而不是bigC

let mainEmbedEmoji1 = await emojiMessageMan1(mainEmbedMsg1, ['1⃣', '2⃣', '3⃣', '4⃣', '6⃣', '8⃣', '?'])