【发布时间】:2020-01-21 17:08:36
【问题描述】:
我只得到了第一个 “moneybag” 表情符号来对频道中的最新消息做出反应,这是机器人发送的嵌入,但是,我希望机器人对频道中的最新消息做出反应新嵌入了 “money bag” 和 “ticket” 表情符号,到目前为止它会与 “money bag” 表情符号做出反应,但是,当它尝试对 "ticket" 表情符号做出反应时出错。如何让机器人对带有两个表情符号的新嵌入做出反应?
if (message.content === '-new') {
const filter = (reaction, user) => {
return ['????', '????'].includes(reaction.emoji.name) && user.id === message.author.id;
};
const embed = new Discord.RichEmbed()
.setTitle('Ticket')
.setColor('DC3BF5')
.setDescription('Thank you for showing interest in purchasing a commission from the Quadra Build Team, or for lending us your time through Support. Make sure you have read our #terms-of-service channel before requesting a commission. We are glad to make your prolific ideas & requests come true!\n\n If you accidentally created a ticket by mistake, use (-del) to delete the ticket.\n\n React with :moneybag: to order a Commission.\n React with :tickets: to create a Support Ticket.\n -------------------------------------------------------------------------------------------------')
message.channel.send(embed)
.then(m => m.react('????'))
.then(m => m.react('????'))
.catch(m => {
console.error('Emoji failed to react.');
});
message.awaitReactions(filter, { max: 1, time: 0, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '????') {
collected.on('collect', () => {
m.clearReactions();
var secondEmbed = new Discord.RichEmbed()
.setTitle('Ticket')
.setColor('DC3BF5')
.setDescription('lol')
});
} else {
collected.on('collect', () => {
m.clearReactions();
var secondEmbed = new Discord.RichEmbed()
.setTitle('Ticket')
.setColor('DC3BF5')
.setDescription('lol 2')
});
}
})
.catch(collected => {
message.channel.send('You didn\'t react with either of the specified emojis.');
});
}
【问题讨论】:
-
错误是什么
-
运行控制台报错"Emoji faile to react."
-
您能否尝试摆脱
.catch(m => { console.error('Emoji failed to react.'); });并告诉我们实际的错误是什么? -
去掉了.catch语句,现在的错误是“m.react is not a statement.”。我相信 M 应该是 Javascript 的标识符,但它在此代码中的目的是确保机器人对其发送的嵌入做出反应,而不是用户的消息。
标签: javascript bots discord discord.js