我已经为verify命令编写了代码,它对某些嵌入做出了反应。但是,当我重新启动时,该漫游器将无法识别它,因此用户仍然可以做出反应,但完全不会扮演角色。我听说我可以使用部分事件,但是我不想在index.js
中使用它。
代码:
let wembed = new Discord.MessageEmbed()
.setAuthor("Test")
.setColor("PURPLE")
.setDescription(arg1)
const reactmessage = await client.channels.cache.get(chx).send(wembed)
await reactmessage.react('✅');
const filter = (reaction, user) => reaction.emoji.name === '✅' && !user.bot;
const collector = reactmessage.createReactionCollector(filter);
collector.on('collect', async reaction => {
const user = reaction.users.cache.last();
const guild = reaction.message.guild;
const member = guild.member(user) || await guild.fetchMember(user);
member.roles.add("725747028323205170");
});
如果有帮助的话,将不胜感激!
答案 0 :(得分:0)
https://discordjs.guide/popular-topics/partials.html#enabling-partials
index.js:
const client = new Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
您的messageReactionAdd文件:
module.exports = async (reaction, user) => {
if(reaction.partial) await reaction.fetch();
}
现在所有反应都发送到messageReactionAdd,现在您只需验证反应并添加角色(如果它对应于正确的表情符号和正确的消息)