loại bỏ phản ứng message.author

Nov 04 2020

Tôi muốn xóa phản ứng của người dùng khi anh ta phản ứng, chỉ để lại một phản ứng của chính bot

Tôi đã xem một số hướng dẫn về điều này, nhưng tôi chưa tìm thấy phương pháp này

const test = new Discord.MessageEmbed()
    .setColor("random")
    .setTitle("help")
    .setDescription(`**this a test**`)

message.channel.send(test).then(msg => {
    msg.react('📚').then(r => {
      msg.react('📌').then(r => {
          })
          })

const hiFilter = (reaction, user) => reaction.emoji.name === '📚' && user.id === message.author.id;
const hi2Filter = (reaction, user) => reaction.emoji.name === '📌' && user.id === message.author.id;

const edit = msg.createReactionCollector(hiFilter);
const edit2 = msg.createReactionCollector(hi2Filter);

edit.on('collect', r2 => {
      
      test.setTitle("test edited")
      test.setDescription("edited")

msg.edit(test)

})
})

Trả lời

Ahsoka Nov 04 2020 at 22:15

Mã này sẽ xóa phản ứng nếu ID của người dùng đã thêm phản ứng không phải là ID của bot của bạn. Thay thế <Client>bằng bất kỳ thứ gì bạn đã khai báo ứng dụng Discord của mình là.

edit.on('collect', (r2, user) => {
    if (user.id !== <Client>.user.id) r2.remove().catch(console.log);

    test.setTitle("test edited");
    test.setDescription("edited");

    msg.edit(test);
});