Пожалуйста помогите мне с ботом для дискорда
я с помощью ютуба сделал бота для discord который выдает роль при нажатии на реакции но он не забирает ее после того как человек убрал свою реакцию. Так же что бы нельзя было получать более 1 роли пока у тебя нажата реакция. Можете ли вы написать что мне надо сделать?
const discord = require('discord.js');
const bot = new discord.Client({disableEveryone: false});
bot.on('ready', () =>
{
bot.channels.cache.get("891060344619954206").fetch("899349881813098548")
.then((msg) =>
{
console.log(msg.content);
});
console.log('Daily BOT started working');
});
var reaRoles = [];
bot.on('message', (message) =>
{
//!w message_id @role@role@role
if (message.content.startsWith('!ReaRole'))
{
let msg = message.content.split(" ");
message.mentions.roles.forEach((role) =>
{
reaRoles.push({"msgID": msg[1], "reacID": "need", "roleID": role.id});
});
for (let i = 0; i < reaRoles.length; i++)
{
if (reaRoles[i].msgID == msg[1])
{
message.channel.send(`<@&${reaRoles[i].roleID}> поставлена на сообщение`);
}
}
}
});
bot.on('messageReactionadd', (reaction, user) =>
{
if (user.bot)
return;
let checker = false;
let msgID = reaction.message.id;
console.log(reaction.emoji.identifier);
for (let i = 0; i < reaRoles.length; i++)
{
if (reaRoles[i].msgID == msgID && !checker && reaRoles[i].reacID == "need")
{
checker = true;
reaction.message.channel.send(`:${reaction.emoji.name}: Обозначается для роли <@&${reaRoles[i].roleID}>`);
reaction.message.react(reaction.emoji);
reaRoles[i].reacID = reaction.emoji.identifier;
}
}
if (checker)
return;
for (let i = 0; i < reaRoles.length; i++)
{
if (reaRoles[i].msgID == msgID && reaRoles[i].reacID == reaction.emoji.identifier)
{
let id = user.id;
reaction.message.guild.members.cache.get(id).roles.add(reaRoles[i].roleID);
}
}
});
bot.login('ТОКЕН БОТА');```