[英]Remove a specific reaction emote on any message (Discord.js)
我想做一个“被禁止的反应”。 我让以下代码正常工作,但它只会删除对机器人发送的消息的反应。
client.on('messageReactionAdd', async (reaction, user) => { console.log(reaction); if(reaction.emoji.name === 'pinkphallicobject') reaction.remove(); });
我怎样才能让它删除对来自任何人的所有消息的特定反应?
要在旧消息上触发messageReactionAdd
事件,您需要在触发ready
事件时将旧消息缓存在服务器中,您可以这样做:
client.once('ready', () => {
var guild = client.guilds.cache.first();// you can find the server you want it to work on in a different way or do this for all servers
guild.channels.cache.forEach(channel => {
if(channel.type == 'text'){//do this for text channels only
channel.messages.fetch({limit: 100}).then(() => {
console.log('cached 100 or less messages from the: ' + channel.name + 'text channel.');
});
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.