首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >等待消息的反应,错误(message.react不是一个函数)

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

Stack Overflow用户
提问于 2020-05-15 08:58:06
回答 1查看 315关注 0票数 0

为什么它说: UnhandledPromiseRejectionWarning: TypeError: message.react不是一个函数,也许它必须这样做,因为这件等待反应的事情已经在等待消息的反应->中了,如果( reaction emoji = C),但是要做什么我必须改变。

代码语言:javascript
复制
} 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⃣', ''])
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-18 14:08:28

emojiMessageMan1函数调用中,您将作为第一个参数bigC传递,这是一个MessageEmbed

但实际上,您需要在反应处理程序中等待一个消息

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

代码语言:javascript
复制
let mainEmbedEmoji1 = await emojiMessageMan1(mainEmbedMsg1, ['1⃣', '2⃣', '3⃣', '4⃣', '6⃣', '8⃣', ''])
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61815473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档