【发布时间】:2020-09-01 01:22:00
【问题描述】:
为什么它说: UnhandledPromiseRejectionWarning: TypeError: message.react is not a function 也许它必须做,因为这个等待反应的东西已经在等待消息反应中 -> 如果(反应表情符号 = C)但我知道我会有什么改变
} 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⃣', '????'])
【问题讨论】:
-
如果你
console.log(bigC)会发生什么?你在bigC上看到react方法了吗? -
缩略图:null,图片:null,视频:null,作者:null,提供者:null,页脚:null,文件:[] 内联:false url:未定义,时间戳:null,类型:未定义,啊,不,我想,但我猜它与嵌入没有任何关系,只有功能或其他东西
-
那么问题来了。您正在调用
emojiMessageMan1(bigC, ...),因此在该函数内部,message现在是bigC,并且您尝试调用与bigC.react相同的message.react- 因此失败。 -
我想我明白你的意思,但我仍然不明白我该如何解决这个问题,我必须以其他方式定义“消息”还是什么?
-
我对@987654330@了解不多,抱歉。
标签: javascript async-await bots discord.js