Discord.js: UnhandledPromiseRejectionWarning on guildMemberUpdate Event

Created on 17 May 2019  Â·  2Comments  Â·  Source: discordjs/discord.js

(node:33392) UnhandledPromiseRejectionWarning: Error: Adding the role timed out. at timeout.client.setTimeout (C:\Users\alexa\Desktop\Skrivbord\Discordbot\node_modules\discord.js\src\client\rest\RESTMethods.js:550:16) at Timeout.setTimeout [as _onTimeout] (C:\Users\alexa\Desktop\Skrivbord\Discordbot\node_modules\discord.js\src\client\Client.js:434:7) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10) (node:33392) 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(). (rejection id: 12)
CONSOLE ERROR: ^

`bot.on('guildMemberUpdate', (oldMember, newMember) => {

var roleMember = '549696099712237602';
var roleMuted = '555328360172093453';
var categoryRolesNoob = '578655959291920387'; //
var colorizeRolesNoob = '578656540261875712'; //

if (newMemberRoles.get(roleMember)
|| newMemberRoles.get(roleMuted)) {
if (!newMemberRoles.get(categoryRolesNoob)) {
newMember.addRole(categoryRolesNoob);
} if (!newMemberRoles.get(colorizeRolesNoob)) {
newMember.addRole(colorizeRolesNoob);
}
} if (!newMemberRoles.get(roleMember)
&& !newMemberRoles.get(roleMuted)) {
if (newMemberRoles.get(categoryRolesNoob)) {
newMember.removeRole(categoryRolesNoob);
} if (newMemberRoles.get(colorizeRolesNoob)) {
newMember.removeRole(colorizeRolesNoob);
} if (!newMemberRoles.get(roleMember)) {
newMember.addRole(roleMember);
}
}
}`
CODE: ^

CODE-FUNCTION: Well, the code function is if a user has roleMember it is going to add categoryRoleNoob and colorizeRoleNoob, if user doesnt have roleMember it is going to remove the other 2 roles. But if roleMember is removed it will re-add roleMember. That works fine.

PROBLEM: The error spam. Is there a way to possibly prevent my bot from sending errors?

PS: Ik the code is probably not well written.

question (please use Discord instead)

Most helpful comment

This doesn't belong in GitHub issues. You're being rate limited because you're modifying roles too often.

Bad functionality design is all this is

All 2 comments

and uh.. what exactly happened with this

Please describe the problem you are having in as much detail as possible:

Include a reproducible code sample here, if possible:

// Place your code here

Further details:

  • discord.js version:
  • Node.js version:
  • Operating system:
  • Priority this issue should have – please be realistic and elaborate if possible:
  • [ ] I have also tested the issue on latest master, commit hash:

This doesn't belong in GitHub issues. You're being rate limited because you're modifying roles too often.

Bad functionality design is all this is

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BrandonCookeDev picture BrandonCookeDev  Â·  3Comments

PassTheMayo picture PassTheMayo  Â·  3Comments

Blumlaut picture Blumlaut  Â·  3Comments

ghost picture ghost  Â·  3Comments

iCrawl picture iCrawl  Â·  3Comments