首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >删除message.author反应

删除message.author反应
EN

Stack Overflow用户
提问于 2020-11-05 05:56:45
回答 1查看 94关注 0票数 1

我想删除用户在做出反应时的反应,只留下一个机器人自己的反应

我已经看过一些关于这个的教程,但是我还没有找到这个方法

代码语言:javascript
复制
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)

})
})
EN

回答 1

Stack Overflow用户

发布于 2020-11-05 06:15:39

如果添加该反应的用户的ID不是你的机器人的ID,则此代码将删除该反应。将<Client>替换为您声明的任何不一致客户端。

代码语言:javascript
复制
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);
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64688286

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档