I am trying to allow the bot to react to itself with both thumbs up and down. here is my code:
const args = message.content.split(' ');
if (message.content.includes('<poll')) {
message.delete()
let embed = new Discord.MessageEmbed()
.setTitle(`Poll In ${message.guild.name}`)
.setDescription(args.slice(1).join(' '))
.setFooter(`Started by ${message.author.username}`)
.setColor('#ffc0cb')
message.channel.send(embed)
.then(sentMessage => sentMessage.react('👍'))
.catch(console.error)
}
I tried using .then
twice but it didn't work.
Try this:
message.channel.send(embed)
.then(sentMessage => {
sentMessage.react('👍')
sentMessage.react('👎')
});
If you want your bot to react in order you have two options:
Use async / await
:
message.channel.send(embed)
.then(sentMessage => {
// Don't forget to make your function async, otherwise it won't work
await sentMessage.react('👍')
await sentMessage.react('👎')
});
Chain .then()
's:
message.channel.send(embed)
.then(sentMessage => sentMessage.react('👍'))
.then(sentMessage => sentMessage.react('👎'))
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.