Discord.js: 验证频道
Discord.js: Verify channel
我正在尝试为我的服务器制作我自己的机器人,目前我专注于验证。通过对复选标记表情符号进行操作,它将添加经过验证的角色,然后它应该只删除用户反应,但它会立即删除所有反应
client.on('messageReactionAdd', async (reactionReaction, user) => {
const message = reactionReaction.message;
const verifyChannel = message.guild.channels.cache.find(c => c.name === 'approvazione');
const member = message.guild.members.cache.get(user.id);
if (member.user.bot) return;
const verify = message.guild.roles.cache.get('728000975046180988');
if (reactionReaction.emoji.name === '✅' && message.channel.id === verifyChannel.id) {
member.roles.add(verify).catch(console.error);
await reactionReaction.remove(member).catch(console.error);
}
here is the message sent by the bot with it's own reaction
and here is the same message after i reacted, and both mine and the bot reaction are removed, i just want my reaction to be removed
如果您查看文档,它不需要用户参数:
https://discord.js.org/#/docs/main/stable/class/MessageReaction?scrollTo=remove
这个在v12改了,现在的方法是用.users.remove
:
reactionReaction.users.remove(member);
我正在尝试为我的服务器制作我自己的机器人,目前我专注于验证。通过对复选标记表情符号进行操作,它将添加经过验证的角色,然后它应该只删除用户反应,但它会立即删除所有反应
client.on('messageReactionAdd', async (reactionReaction, user) => {
const message = reactionReaction.message;
const verifyChannel = message.guild.channels.cache.find(c => c.name === 'approvazione');
const member = message.guild.members.cache.get(user.id);
if (member.user.bot) return;
const verify = message.guild.roles.cache.get('728000975046180988');
if (reactionReaction.emoji.name === '✅' && message.channel.id === verifyChannel.id) {
member.roles.add(verify).catch(console.error);
await reactionReaction.remove(member).catch(console.error);
}
here is the message sent by the bot with it's own reaction
and here is the same message after i reacted, and both mine and the bot reaction are removed, i just want my reaction to be removed
如果您查看文档,它不需要用户参数:
https://discord.js.org/#/docs/main/stable/class/MessageReaction?scrollTo=remove
这个在v12改了,现在的方法是用.users.remove
:
reactionReaction.users.remove(member);