mHu*_*ing 4 javascript bots discord discord.js
我只得到了第一个“钱袋”表情符号来对频道中的最新消息做出反应,这是机器人发送的嵌入,但是,我希望机器人对新嵌入做出反应,同时使用“钱袋”和“票”表情符号,到目前为止,它会与“钱袋”表情符号做出反应,但是当它尝试与“票”表情符号做出反应时,会出错。如何让机器人对带有两个表情符号的新嵌入做出反应?
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.');
});
}
Run Code Online (Sandbox Code Playgroud)
Message#react 在承诺中返回 MessageReaction,因此您需要执行以下操作:
message.channel.send(embed)
.then(m => m.react(''))
.then(m => m.message.react(''))
Run Code Online (Sandbox Code Playgroud)
或者
message.channel.send(embed)
.then(m => {
m.react('')
m.react('')
});
Run Code Online (Sandbox Code Playgroud)
或使用异步等待:
const m = await message.channel.send(embed);
await m.react('')
await m.react('')
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4793 次 |
最近记录: |