question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discord.js v13 needs guildId in permissions

See original GitHub issue

Describe the bug Since Discord.js V13 all permissions needs a guildId whatever it’s a global or a guild slash command

To Reproduce Steps to reproduce the behavior:

  1. Install last Discord.js version > 13.0
  2. Write a new permission on your discord config
  3. Nothing more

Expected behavior An error should occur in the nestjs console

Screenshots image

*Stacktrace

/srv/discord.limit-gif/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:377
    if (!guildId) throw new Error('GLOBAL_COMMAND_PERMISSIONS');
                        ^
Error [GLOBAL_COMMAND_PERMISSIONS]: Permissions for global commands may only be fetched or modified by providing a GuildResolvable or from a guild's application command manager.
    at ApplicationCommandPermissionsManager._validateOptions (/srv/discord.limit-gif/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:377:25)
    at ApplicationCommandPermissionsManager.set (/srv/discord.limit-gif/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:162:41)
    at RegisterCommandService.<anonymous> (/srv/discord.limit-gif/node_modules/@discord-nestjs/core/src/services/register-command.service.ts:236:37)
    at Generator.next (<anonymous>)
    at /srv/discord.limit-gif/node_modules/@discord-nestjs/core/dist/services/register-command.service.js:20:71
    at new Promise (<anonymous>)
    at __awaiter (/srv/discord.limit-gif/node_modules/@discord-nestjs/core/dist/services/register-command.service.js:16:12)
    at /srv/discord.limit-gif/node_modules/@discord-nestjs/core/src/services/register-command.service.ts:230:53
    at Array.map (<anonymous>)
    at RegisterCommandService.<anonymous> (/srv/discord.limit-gif/node_modules/@discord-nestjs/core/src/services/register-command.service.ts:229:32)

Environment

Additional context Adding an mandatory guildId Type string containing the guildId on Interface SlashCommandPermissions and sending it to discord.js

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Arkmindcommented, May 8, 2022

So after a few more researches i’ve finally understood why permissions by command ain’t working anymore Here’s the Discord.js post :

Discord is rolling out Slash Command Permissions v2 to all guilds - it is no longer possible to set slash command > permission overrides

Blog post: https://discord.com/blog/slash-commands-permissions-discord-apps-bots Documentation PR: https://github.com/discord/discord-api-docs/pull/4830

Permissions v2 removes access to the endpoint for bots to set permission overrides on commands. Server admins are now responsible for managing slash command permissions themselves via the server settings. default_permission is now split into default_member_permissions for guilds, and dm_permission for DMs.

Thanks for the replies, I’m closing this issue ! 💯

0reactions
fjodor-rybakovcommented, Jun 15, 2022

So after a few more researches i’ve finally understood why permissions by command ain’t working anymore Here’s the Discord.js post :

Discord is rolling out Slash Command Permissions v2 to all guilds - it is no longer possible to set slash command > permission overrides

Blog post: https://discord.com/blog/slash-commands-permissions-discord-apps-bots Documentation PR: discord/discord-api-docs#4830

Permissions v2 removes access to the endpoint for bots to set permission overrides on commands. Server admins are now responsible for managing slash command permissions themselves via the server settings. default_permission is now split into default_member_permissions for guilds, and dm_permission for DMs.

Thanks for the replies, I’m closing this issue ! 💯

@fjodor-rybakov Isn’t this still an issue with the current DiscordModule implementation? The issue was closed, but a solution in the module wasn’t identified and therefore the entire permissions system doesn’t work anymore in the module. When using guild commands, with the permissions defined in the module factory as shown in the documentation, the following error occurs. Don’t we need to make sure we’re supporting Permissions v2 for both guild and command permissions. With the new system, the permissions we specify should be the command’s default permissions. image

Wait for this discordjs/discord.js#7857 please

Looks like this has all been approved and merged. 🙂

Everything seems to be working now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Permissions - discord.js Guide
Permissions. Permissions are Discord's primary feature, enabling users to customize their server's workings to their liking.
Read more >
Permissions - Discord Developer Portal — Documentation
Permissions are a way to limit and grant certain abilities to users in Discord. A set of base permissions can be configured at...
Read more >
403 Error when setting application command permissions on ...
Discord has released Permissions V2 to all guilds yesterday (April ... const guildId = "GUILD_ID" const url = `https://discord.com/api/v9/ ...
Read more >
discordjs-bot-guide/roles.md at master - GitHub
The bot requires MANAGE_ROLES permissions for this. You can check for it using the code further down this page. Because of global rate...
Read more >
Discord Slash Command Permissions - Discord.js v14
Support the Channel:Become a Member: https://www.youtube.com/ansonthedeveloper/joinBecome a Patreon: http://patreon.com/stuyyBuy me a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found