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: 405: Method Not Allowed | Crashes While Bot is Invited to Any Server

See original GitHub issue

What’s happening? Crashes immediately after inviting to a server. Tested changing permission integer to 8 (Administrator) out of curiosity but no change. Have invited it to two servers. One I am the owner of, the other I just have manage server permissions. Only invited the bot to the server I own as Administrator. Each subsequent attempt to run the bot while it is in any guild will crash until the bot is kicked from all servers. Appears to crash while processing permissions.

Logs

✔ Database migrations applied.
✔ Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=<censored>&scope=bot%20applications.commands&permissions=36700288
/root/muse/node_modules/discord.js/src/rest/RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: 405: Method Not Allowed
    at RequestHandler.execute (/root/muse/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/root/muse/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async ApplicationCommandPermissionsManager.set (/root/muse/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:186:18)
    at async updatePermissionsForGuild (file:///root/muse/src/utils/update-permissions-for-guild.ts:32:3)
    at async Client.guild_create_default (file:///root/muse/src/events/guild-create.ts:36:3) {
  method: 'put',
  path: '/applications/968996889099911238/guilds/450306155361861632/commands/permissions',
  code: 0,
  httpStatus: 405,
  requestData: {
    json: [
      {
        id: '968999097581322281',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322282',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322283',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322284',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322285',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322286',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322287',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322288',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322289',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097581322290',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097652637696',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097652637697',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097652637698',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097652637699',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097652637700',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097652637701',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097652637702',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      },
      {
        id: '968999097652637703',
        permissions: [
          { id: '148334523514486784', permission: true, type: 2 },
          { id: '450306155361861632', permission: false, type: 1 },
          { id: '148334523514486784', permission: true, type: 2 }
        ]
      }
    ],
    files: []
  }
}
file:///root/muse/node_modules/execa/lib/error.js:59
                error = new Error(message);
                        ^

Error: Command failed with exit code 1: esmo src/scripts/migrate-and-start.ts
    at makeError (file:///root/muse/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///root/muse/node_modules/execa/index.js:119:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async file:///root/muse/src/scripts/run-with-database-url.ts:5:3 {
  shortMessage: 'Command failed with exit code 1: esmo src/scripts/migrate-and-start.ts',
  command: 'esmo src/scripts/migrate-and-start.ts',
  escapedCommand: 'esmo "src/scripts/migrate-and-start.ts"',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Screenshots N/A

Additional context Fresh install of v1.9.0 branch. Installed using command npm i. Run using command npm run start.

Runtime I’m running Muse:

  • Directly from the cloned repository
  • Inside a Docker container
  • Something else (please elaborate)

Versions

  • Muse: 1.9.0
  • Docker (if applicable): N/A
  • OS: Ubuntu Server 16.04 LTS

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:35 (15 by maintainers)

github_iconTop GitHub Comments

5reactions
kkendziacommented, Apr 28, 2022

Issue due to breaking change in discord API from April 27th: https://discord.com/developers/docs/change-log

Disabled the batch editing endpoint ([PUT /applications/{application.id}/guilds/{guild.id}/commands/permissions](https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions)).

3reactions
codethewebcommented, Apr 29, 2022

I’ll try to take a look at this tomorrow.

PRs welcome if someone figures out a fix. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - 405 Error while creating a channel in Discord ...
1 Answer 1 · Go to User Settings > Advanced in Discord. · Turn on Developer Mode. · Right click the icon of...
Read more >
Errors | discord.js Guide
API Errors or DiscordAPIErrors are thrown by the Discord API when an invalid request ... meaning your process should never crash from them....
Read more >
Opcodes and Status Codes - Developer Portal
405 (METHOD NOT ALLOWED), The HTTP method used is not valid for the location specified. ; 429 (TOO MANY REQUESTS), You are being...
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 >
throw new discordapierror.discordapierror(data, "code" in ...
It appears that the Bot and the users were not sharing a server, thus this error was ... DiscordAPIError: 405: Method Not Allowed...
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