#Error: Error code must be a valid DiscordjsErrorCodes

26 messages · Page 1 of 1 (latest)

lapis lark
#

In my client class I have the following code:

getInvite(){
        return this.generateInvite({
            scopes: ["bot", "applications.commands"],
            permissions: [
                "ViewAuditLog", "ManageRoles", "ManageChannels", "KickMembers", "BanMembers",
                "ManageEmojisAndStickers", "ManageWebhooks", "ViewChannel", "SendMessages",
                "ManageMessages", "AttachFiles", "EmbedLinks", "ReadMessageHistory", "UseExternalEmojis",
                "AddReactions"
            ]
        })
    }```

using the functions returns the following error:
`Error: Error code must be a valid DiscordjsErrorCodes`

When using djs 14.9.0 it works as it should
fading pewterBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

lapis lark
#

discord.js 14.10.0, node 19.1.0

#
    at message (C:\Users\Jonas\Desktop\Jonas\Projekte\Nevar\Bot\v5\node_modules\discord.js\src\errors\DJSError.js:35:36)
    at new DiscordjsError (C:\Users\Jonas\Desktop\Jonas\Projekte\Nevar\Bot\v5\node_modules\discord.js\src\errors\DJSError.js:16:13)
    at BaseClient.generateInvite (C:\Users\Jonas\Desktop\Jonas\Projekte\Nevar\Bot\v5\node_modules\discord.js\src\client\Client.js:424:13)
    at BaseClient.getInvite (C:\Users\Jonas\Desktop\Jonas\Projekte\Nevar\Bot\v5\src\structures\BaseClient.js:272:21)
    at module.exports.dispatch (C:\Users\Jonas\Desktop\Jonas\Projekte\Nevar\Bot\v5\src\events\message\MessageCreate.js:67:110)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)```
pulsar tree
#

That should work, you met a new error code that got introduced in v14.10.0 but I just double checked and it‘s there… can you try reinstalling djs?

lapis lark
#

i found in the changelog the issue that describes that ManageEmojisAndStickers was renamed to ManageGuildExpressions which effects the ErrorCodes.js

#

but when I rename the permission it still gives me this error

pulsar tree
#

Can you do me a favor and console.log(ErrorCodes) after importing it from discord.js?

lapis lark
#

undefined

pulsar tree
#

Oh, DiscordjsErrorCodes my bad

lapis lark
pulsar tree
#

Found the issue, there‘s a typo in the error codes…

lapis lark
#

oh

#

i guess then i'll have to wait for a new version right?

foggy spruce
#

that just affects the error message being shown, the root error still is being thrown though. i think the invalid error code is InvalidScope(s)WithPermissions so the real message would be 'Permissions cannot be set without the bot scope.'

lapis lark
#

hmh okay

foggy spruce
#

i'd wait for Qjuh to confirm but from what i can see, rolling back to 14.9.0 is probably needed

lapis lark
#

than thats probably the best way, thank you both :)

onyx relic
#

@foggy spruce @lapis lark install 14.10.1

blissful nimbus
#

the validation is still incorrect, its just that it will show the error correctly now

foggy spruce
#

cool, thanks for following up with both fixes

onyx relic
#

@foggy spruce @lapis lark update to 14.10.2 (:

lapis lark
#

Thank you all :)