'To Discord.js master [duplicate]

i got an error. PLZ HELP ME!! I tried the slash command bot. And i have been getting this error. I have tried hard to solve this error. I gave the bot full permission. So, I don't know what to do, so I ask here.

Error content: https://pastebin.com/G0CH6QBK

      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: 405: Method Not Allowed
    at RequestHandler.execute (/data/data/com.termux/files/home/CM/node_modules/discord.js/src/rest/RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/data/data/com.termux/files/home/CM/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
    at async ApplicationCommandPermissionsManager.set (/data/data/com.termux/files/home/CM/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:186:18)
    at async /data/data/com.termux/files/home/CM/Handlers/Commands.js:60:5 {
  method: 'put',
  path: '/applications/971797595313827931/guilds/951450095658872853/commands/permissions',
  code: 0,
  httpStatus: 405,
  requestData: {
    json: [
      {
        id: '972066482475393044',
        permissions: [
          { id: '951450095658872853', permission: true, type: 1 },
          { id: '951469564242321419', permission: true, type: 1 },
          { id: '951497606733918221', permission: true, type: 1 },
          { id: '951504382413926450', permission: true, type: 1 },
          { id: '952860149054312499', permission: true, type: 1 },
          { id: '959619628022259735', permission: true, type: 1 },
          { id: '961465754526576652', permission: true, type: 1 },
          { id: '971431284519870555', permission: true, type: 1 },
          { id: '971431411804409917', permission: true, type: 1 },
          { id: '971432006678376539', permission: true, type: 1 },
          { id: '971432790254030868', permission: true, type: 1 },
          { id: '971435796450140241', permission: true, type: 1 },
          { id: '971443167545163886', permission: true, type: 1 },
          { id: '971444177873285130', permission: true, type: 1 },
          { id: '971516546834890814', permission: true, type: 1 },
          { id: '971690107688083522', permission: true, type: 1 },
          { id: '971952762319421470', permission: true, type: 1 },
          { id: '971953522901909524', permission: true, type: 1 },
          { id: '972066442621120556', permission: true, type: 1 }
        ]
      }
    ],
    files: []
  }
}```


Solution 1:[1]

First of all, in the future, please provide your code. It is obviously incredibly difficult to solve issues with your code, if you don't even show us a line of your code.

Second, this issue has nothing to do with discord.js or code, hence why I'm able to answer your question without being provided any of your code. The issue is that Discord recently updated its slash command permissions system across all applicable versions of the API. They removed the HTTP endpoint to bulk-update permissions for all slash commands at once, and phased out bots' ability to control command permissions. Command permissions can now only be controlled by users/ Hence, ApplicationCommandPermissionsManager.set() will not work for you anymore.

You have two options. If you want to use the actual permissions system, you can authenticate with the admin user and control command permissions through them. The second option is to not use the permissions system, and instead manually check permissions with your bot on command use (though this will not show commands as disabled to users who do not have perms to use the command).

See the updated documentation for the permissions system.

Ignore the snippet of code that was previously included with this answer, as I misinterpreted the announcement about the changes made to the permissions system. The answer to your question is: it's not possible.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1