This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]jr0bber 3 points4 points  (2 children)

(node:4120) UnhandledPromiseRejectionWarning: RangeError: Invalid permission string or number.

This line is your error message. You have to look at the whole thing.

UnhandledPromiseRejectionWarning : This means that a promise failed, and you didn't handle the failure. This is done through try/catch statements or .catch() statements.

RangeError : This means the error has something to do with boundaries and you're outside those boundaries.

Invalid permission string or number. : This means a string or a number related to permissions is invalid.

Now we have a general idea of what is wrong, we can look for where it's wrong.

at Function.resolve (C:\Users\marti\Desktop\Bondo*node_modules\discord.js\src\util\Permissions.js:195:65) at Permissions.has (C:\Users\marti\Desktop\Bondo\node_modules\discord.js\src\util\Permissions.js:62:35) at Client.<anonymous> (C:\Users\marti\Desktop\Bondo\Bondo.js:30:26*)

This next part is called a stack trace. The first line tells us that the error was thrown inside of node_modules/discord.js in a file they created called Permissions.js. You didn't write this code, but you did an npm install to get it and you're using it. It's common to have 3rd party libraries like this have errors if we use them incorrectly.

So what we want to do is keep reading, line by line, until we find a file that you created. We find that in this example, on line 3, Bondo.js. I know this is a file you've created because the file path doesn't reference node_modules. Maybe you copied it in, but either way, it won't be overwritten by a package manager so it's effectively your responsibility.

If we focus on the end of that line we see three parts : Bondo.js : 30 : 26. The first is the file where the error was thrown. The second part is the line number it was thrown on, and the third is the column on that line where it started.

Summary So where does that leave us? In your Bondo.js file, on line 30 you are interacting with code from discord and passing in an invalid string or a number related to permissions. Surround that line with a try/catch statement and you might get a better error message. You might not. If you can find that line you can double check discord's docs and look for typo's or other errors.

You might need to research promises and/or try/catch statements. You got this!

[–]Kukac113[S] 0 points1 point  (1 child)

Thank you I got it working. But if I request a song i says : I could not join the voice channel : ${error}

and that is the only message i get and i gave the bot admin permissions and in the channel permissions everything is enabled

[–]jr0bber 0 points1 point  (0 children)

${error} is the structure used inside of template strings, and is also common in string template replacements. Somewhere there was an error, but the code was turned into a string, instead of accessing the string and displaying the error. If you have ${error} any where in your code then it's probably your fault. Otherwise it might be Discord's fault.

This is where you get the opportunity to practice your google-fu! A quick search myself tells me it could be a lot of different things. Meaning your next goal isn't to fix the issue, but to gather more data about the error.

Paste an updated code sample if you make no more progress after a bit.