检查具有特定角色的用户是否对最新的机器人程序消息|Discord.js做出了反应



我需要让我的机器人检查是否有管理员角色或特定角色的人对机器人的最新消息做出了反应

我为我的机器人程序制作了一个建议命令,我想让机器人程序检查是否有@Admin角色的人对#建议频道的最新机器人程序消息做出了反应,然后当拥有@Admin角色的用户对建议做出反应时,让机器人程序向我发送一个DM,告诉我:接受你的建议

以下是可能有所帮助的内容:

client.on('messageReactionAdd', async (reaction, user) {
if(reaction.message.channel.id !== 'suggestion channel id') return;
let channel = reaction.message.channel;
let msg = await channel.messages.fetch({limit: 1});
if(!msg || msg.id !== reaction.message.id) return;
if(reaction.message.guild.member(user).roles.cache.some(r => r.id === 'admin role id')) {
user.send('Your suggestion was accepted.')
//You may have said this wrong, but if you want the person who suggested it to be DMd
//You will need to somehow save their name (or id which can never change), let’s say you put it in the footer of an embed for the suggestion
let userID = reaction.message.embeds[0].footer;
msg.guild.members.cache.find(m => m.user.id === userID).send('Accepted your suggestion!')
}
})

我想知道这是否不起作用,因为我没有测试它。它可能有一些错误,但希望不是

最新更新