Я не могу получить реакцию на работу, чтобы назначить или удалить роли - PullRequest
0 голосов
/ 03 июля 2019

Цель состоит в том, чтобы добавить пользователю роль «скрим», если он / она нажимает на реакцию «+», и удалить эту роль, если он / она нажимает снова (удаляет реакцию).Это просто, но по какой-то причине не будет работать.

bot.on('messageReactionAdd', (reaction, user) => {
    //Not the best way for checking that the message is valid, should be made better at some point
    if (reaction.emoji.name == '➕' && user.id != bot.user.id && reaction.message.author.id == bot.user.id && reaction.message.content.includes("Game created in")) {
        config.scanForMsdID(reaction.message.id, reaction.message.guild.id).then(ret => {
            config.addUser(reaction.message.guild.id, config.getRoleByReaction(reaction, reaction.message.guild.id), user.id).then(data => {
                if (data == 'full') {
                    MESSAGE.channel.sendMessage('**' + GAME + '** is now full!');
                }
            });
            reaction.message.guild.member(user).addRole(config.getRoleByReaction(reaction, reaction.message.guild.id)); //TODO
        });
    }
});
bot.on('messageReactionRemove', (reaction, user) => {
    if (reaction.emoji.name == '➕' && user.id != bot.user.id && reaction.message.author.id == bot.user.id && reaction.message.content.includes("Game created in")) {
        config.scanForMsdID(reaction.message.id, reaction.message.guild.id).then(ret => {
            config.removeUser(reaction.message.guild.id, config.getRoleByReaction(reaction, reaction.message.guild.id), user.id);
            reaction.message.guild.member(user).removeRole(config.getRoleByReaction(reaction, reaction.message.guild.id));
        });
    }
});
...