Discord.js: guildMember.AddRole successfully adds role, but gets "Error: Adding the role timed out."

Created on 13 Dec 2020  路  2Comments  路  Source: discordjs/discord.js

I am trying to setup a simple react role handler for my discord bot. The role gets added successfully, but I get the following error:

(node:17872) UnhandledPromiseRejectionWarning: Error: Adding the role timed out.
at C:UsersUserDocumentsjs_projectsdiscord-bot-sitepointnode_modulesdiscord.jssrcclientrestRESTMethods.js:560:16
at Timeout._onTimeout (C:UsersUserDocumentsjs_projectsdiscord-bot-sitepointnode_modulesdiscord.jssrcclientClient.js:436:7)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
(node:17872) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on
unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17872) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

bot.on("messageReactionAdd", async (messageReaction: Discord.MessageReaction, user: Discord.User) => {
    if (messageReaction.message.channel.id == REACT_ROLE_CHANNEL_ID) {
        let allRoles = messageReaction.message.guild.roles;
        let reactingMember = messageReaction.message.member;
        let reactWhiteBeltRole = reactingMember.roles.find(r => r.name === "White Belt");
        if (!reactWhiteBeltRole) {
            let wbRole = allRoles.find(r => r.name === "White Belt");
            let member = messageReaction.message.guild.member(user);
            member = await member.addRole(wbRole);
        }
    }
});

Further details:

  • discord.js version: 11.6.4
  • Node.js version: 14.14.13
  • Operating system: Windows 10
invalid unverified bug

Most helpful comment

we no longer provide support for or maintain usability of v11.

All 2 comments

I updated to v12 and everything worked fine

we no longer provide support for or maintain usability of v11.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shukriadams picture shukriadams  路  3Comments

Blumlaut picture Blumlaut  路  3Comments

kvn1351 picture kvn1351  路  3Comments

ghost picture ghost  路  3Comments

Acaretia picture Acaretia  路  3Comments