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.

DiscordAPIError: Bots cannot use this endpoint

See original GitHub issue

Describe the bug I’ve updated my Discord NestJS to version (3.3.4) but unfortunately I’m still running into issues with registering Discord slash commands with permissions.

[Nest] 16152  - 16/06/2022, 21:34:10     LOG [NestApplication] Nest application successfully started +747ms
[Nest] 16152  - 16/06/2022, 21:34:31     LOG [RegisterCommandService] All guild commands removed!
[Nest] 16152  - 16/06/2022, 21:34:31     LOG [RegisterCommandService] All guild commands are registered!

...\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 (...\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at RequestHandler.push (...\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at ApplicationCommandPermissionsManager.set (...\node_modules\discord.js\src\managers\ApplicationCommandPermissionsManager.js:168:20)

To Reproduce My configuration is as follows (I have removed all commands that were not required to produce the error, it looks like any command triggers it):

{
    token: appConfiguration.token,
    discordClientOptions: {
        intents: Object.keys(Intents.FLAGS).map(
            (i) => Intents.FLAGS[i] // temporary, while developing
        )
    },
    removeGlobalCommands: true,
    registerCommandOptions: [
        {
            forGuild: appConfiguration.guildId,
            removeCommandsBefore: true
        }
    ],
    slashCommandsPermissions: [
        {
            commandClassType: URLCommand,
            permissions: [
                {
                    id: permissionConfiguration.staffRole, // string id
                    type: ApplicationCommandPermissionTypes.ROLE,
                    permission: true // default false, in the @Command()
                }
            ]
        }
    ]
};
"dependencies": {
    "@discord-nestjs/common": "^3.3.4",
    "@discord-nestjs/core": "^3.3.4",
    "@nestjs/common": "^8.0.0",
    "@nestjs/config": "^1.2.0",
    "@nestjs/core": "^8.0.0",
    "@nestjs/event-emitter": "^1.1.0",
    "@nestjs/mapped-types": "*",
    "@nestjs/platform-express": "^8.0.0",
    "@nestjs/schedule": "^1.1.0",
    "@nestjs/typeorm": "^8.0.3",
    "@shockbyte/nest-common": "^0.0.5",
    "discord.js": "^13.*",
    "husky": "^7.0.4",
    "mysql2": "^2.3.3",
    "nestjs-dynamic-providers": "^0.1.2",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.2.0",
    "typeorm": "^0.2.45"
}

Expected behavior Prior to the DiscordAPI command changes, this configuration worked as expected and commands were protected by the needed permissions.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
TheFlash787commented, Jul 2, 2022

Alright, so this will be fairly easy to accomplish once this is complete – we may just need to rework how the permissions are handled a little, but the tools should be there: https://github.com/discordjs/discord.js/pull/8162

We would basically need to change await command.permissions.set({ permissions }); to use the command.setDefaultXXX methods when this PR is accessible for us to use in DiscordJS v13.

1reaction
TheFlash787commented, Jun 24, 2022

@fjodor-rybakov Since this error is still occuring and easily replicatable with slashComandPermissions in use on the sample projects, is it possible we could re-open this issue so that we can track our resolution process?

Read more comments on GitHub >

github_iconTop Results From Across the Web

403 Error when setting application command permissions on ...
Discord has released Permissions V2 to all guilds yesterday (April 27, 2022). Bots can no longer control the permissions, ...
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 >
Search Endpoint For Bots #1754 - discord/discord-api-docs
I was hoping to use the search endpoint to all... ... { DiscordAPIError: Bots cannot use this endpoint at item.request.gen.end ...
Read more >
Errors - discord.js Guide
API Errors or DiscordAPIErrors are thrown by the Discord API when an invalid request carries out. API Errors can be mostly diagnosed using...
Read more >
throw new discordapierror.discordapierror(data, "code" in data ...
I can't send a private message to a user in discord with node.js ... It appears that the Bot and the users were...
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