Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

589
Views
HTTP error code 405 Invalid method for DiscordJS bot

I'm making a new discord bot to help me learn discordjs and JS in general but I keep getting the following HTTP error and cannot find a way to resolve it. Using discord.js version 13.8.0

See error message:

DiscordAPIError: 405: Method Not Allowed
    at RequestHandler.execute (C:\Users\Offic\Desktop\___\LearningBot\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\Offic\Desktop\___\LearningBot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async ApplicationCommandPermissionsManager.set (C:\Users\Offic\Desktop\___\LearningBot\node_modules\discord.js\src\managers\ApplicationCommandPermissionsManager.js:186:18)
    at async C:\Users\Offic\Desktop\___\LearningBot\handlers\commands.js:66:12 {
  method: 'put',
  path: '/applications/986771474943709244/guilds/986441402735022140/commands/permissions',
  code: 0,
  httpStatus: 405,
  requestData: { json: [], files: [] }

The following is the faulty code snippet:

    client.on("ready", async () => {
        const MainGuild = await client.guilds.cache.get(process.env.GUILDID);

        MainGuild.commands.set(commandsarray).then(async (command) => {
           const Roles = (commandname) => {
            const cmdperms = commandsarray.find((c) => c.name === commandname).permission;
            if(!cmdperms) return null;

            return MainGuild.roles.cache.filter((r) => r.permissions.has(cmdperms));
           }

           const fullPermissions = command.reduce((accumulator, r) => {
                const roles = Roles(r.name);
                if(!roles) return accumulator;

                const permissions = roles.reduce((a, r) => {
                    return [...a, {id: r.id, type: "ROLE", permission: true}]
                }, []);
                
                return [...accumulator, {id: r.id, permissions}]
           }, []);

           await MainGuild.commands.permissions.set({ fullPermissions });
        });
    });

The section where the error occurs is:

await MainGuild.commands.permissions.set({ fullPermissions });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!