Ad

Await Message Reaction In A Message Await Reaction, Error (message.react Is Not A Function)

Whyever it says : UnhandledPromiseRejectionWarning: TypeError: message.react is not a function maybe it has to do because this await reactiont thing is already in a await message reaction -> if ( reaction emoji = C) but idk what i would have to change

} 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⃣', '🔟'])
Ad

Answer

In emojiMessageMan1 function call you are passing as first parameter bigC which is a MessageEmbed.

But you actually wait for a Message in your reaction handler.

So you have to pass mainEmbedMsg1 instead of bigC :

let mainEmbedEmoji1 = await emojiMessageMan1(mainEmbedMsg1, ['1⃣', '2⃣', '3⃣', '4⃣', '6⃣', '8⃣', '🔟'])
Ad
source: stackoverflow.com
Ad