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.

[Bug]: DiscordAPIError: Bots cannot use this endpoint

See original GitHub issue

What happened?

My guild was moved to v2 of the permissions system and now it’s failing to start.

Reproduction

From the demo repo.

// init permissions; enabled log to see changes
await client.initApplicationPermissions(true);

Package

discordx

Version

Stable

Relevant log output

Charlotte >> command: kick >> permissions >> updating >> guild: #The lobby
C:\Users\xo\code\OmgImAlexis\charlotte\node_modules\discord.js\src\rest\RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^
DiscordAPIError: Bots cannot use this endpoint
    at RequestHandler.execute (C:\Users\xo\code\OmgImAlexis\charlotte\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\xo\code\OmgImAlexis\charlotte\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async ApplicationCommandPermissionsManager.set (C:\Users\xo\code\OmgImAlexis\charlotte\node_modules\discord.js\src\managers\ApplicationCommandPermissionsManager.js:168:20)
    at async file:///C:/Users/xo/code/OmgImAlexis/charlotte/node_modules/discordx/src/Client.ts:833:15
    at async Promise.all (index 12)
    at async Client.initGuildApplicationPermissions (file:///C:/Users/xo/code/OmgImAlexis/charlotte/node_modules/discordx/src/Client.ts:816:5)
    at async Promise.all (index 0)
    at async Client.initApplicationPermissions (file:///C:/Users/xo/code/OmgImAlexis/charlotte/node_modules/discordx/src/Client.ts:776:5)
    at async Client.<anonymous> (file:///C:/Users/xo/code/OmgImAlexis/charlotte/src/client.ts:37:5) {
  method: 'put',
  path: '/applications/962572053003796551/guilds/927461441051701280/commands/968148318783942756/permissions',
  code: 20001,
  httpStatus: 403,
  requestData: { json: { permissions: [] }, files: [] }
}

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
samarmeenacommented, May 15, 2022

with v9.6.0, this feature is temporary disabled in discordx. We will update accordingly discord.js.

1reaction
VictoriqueMoecommented, Apr 28, 2022

Update:

the docs have been merged, and the API still exists, however, the reason why you where getting this error is because there is a NEW authentication needed to call the Permission set api: https://discord.com/developers/docs/interactions/application-commands#permissions

Command permissions can only be updated using a Bearer token. Authenticating with a bot token will result in an error.

As we can see, the API is still the same https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions but now requires a Bearer token with the applications.commands.permissions.update

HOWEVER, there IS a new field called default_member_permissions https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-using-default-permissions

Adding default permissions doesn’t require any Bearer token since it’s configured during command creation and isn’t targeting specific roles, users, or channels.

This is likely replacing the permission decorator we have with the boolean as it says:

Added default_member_permissions field, which is a bitwise OR-ed set of permissions, expressed as a string. This replaces the default_permission field, which will soon be deprecated.

https://discord.com/developers/docs/change-log#updated-command-permissions

Read more comments on GitHub >

github_iconTop Results From Across the Web

403 Error when setting application command permissions on ...
My bot got a 403 error, even though it never happened before, and the code hasn't changed at all. The paths /applications/{applicationId}/ ...
Read more >
Why can't bots use this endpoint? - Discord Support
js doesn't use it) authenticated as the bot, I got the following error: `{"message": "Bots cannot use this endpoint", "code": 20001}`. The error...
Read more >
InteractionService.ModifySlashCommandPermissionsAsync ...
InteractionService.ModifySlashCommandPermissionsAsync() fails with API error 20001: Bots cannot use this endpoint. It seems like Discord.Net ...
Read more >
Errors - discord.js Guide
This error throws when the bot attempts to send a DM message to a user but cannot do so. A variety of reasons...
Read more >
How Roles cause Missing Permission Errors in Discord.js
After struggling to understand why my Discord.js bot was throwing a DiscordAPIError: Missing Permissions even with full admin permissions, I found out that ......
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