Discord.js: addMemberToRole and removeMemberFromRole

Created on 25 Jul 2016  Â·  2Comments  Â·  Source: discordjs/discord.js

Hi, i just want to assign and remove a role to the same user. Sometimes the bot assigns Role1 but does not remove the Role2 or remove the Role2 but does not assign Role1. No error in the console logs.

My code

//ASSIGN ROLE
role = message.server.roles.get("name", 'Role1');
mybot.addMemberToRole(user, role, function (err) {
    if (err) {
        console.log(err);
    }
})

//REMOVE ROLE
role = message.server.roles.get("name", 'Role2');
mybot.removeMemberFromRole(user, role, function (err) {
    if (err) {
        console.log(err);
    }
});
question (please use Discord instead) duplicate

Most helpful comment

Essentially a duplicate of #472

All 2 comments

Nest it in the callback

On Mon, Jul 25, 2016, 20:46 Julio Cesar Peña Velasquez <
[email protected]> wrote:

Hi, i just want to assign and remove a role to the same user. Sometimes
the bot assigns Role1 but does not remove the Role2 or remove the Role2 but
does not assign Role1. No error in the console logs.

My code

//ASSIGN ROLE
role = message.server.roles.get("name", 'Role1');
mybot.addMemberToRole(user, role, function (err) {
if (err) {
console.log(err);
}
})

//REMOVE ROLE
role = message.server.roles.get("name", 'Role2');
mybot.removeMemberFromRole(user, role, function (err) {
if (err) {
console.log(err);
}
});

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/hydrabolt/discord.js/issues/476, or mute the thread
https://github.com/notifications/unsubscribe-auth/AMoLtigdsdXaAhr8ANR6R9WAAZxkg7BHks5qZQSagaJpZM4JUbPv
.

Essentially a duplicate of #472

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Blumlaut picture Blumlaut  Â·  3Comments

LLamaFTL picture LLamaFTL  Â·  3Comments

ghost picture ghost  Â·  3Comments

kvn1351 picture kvn1351  Â·  3Comments

tom-barnes picture tom-barnes  Â·  3Comments