'DiscordJS Error POST-FAILED Code: 50001 remove error message

im owning a Discord bot for music and stuff. My console always gets spammed full with this message:

20:2:2022 - 17:22 | Info: [Slash Command]: [POST-FAILED] Guild 945348402374385736, Command: youtube
DiscordAPIError: Missing Access
    at RequestHandler.execute (/home/m9mo/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async RequestHandler.push (/home/m9mo/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
    at async /home/m9mo/util/RegisterSlashCommands.js:36:9 {
  method: 'post',
  path: '/applications/895283932252241940/guilds/945348402374385736/commands',
  code: 50001,
  httpStatus: 403
}

I know the reason for this error but some people are creating their own invite link using the id of the bot... Is there any way to disable this message?



Solution 1:[1]

You could try finding the error code (In this case 50001) of that specific error, then when you receive an error, stop it from being logged. You can find all the relevant error codes here: https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes

You might also want to consider sending some kind of message like I'm missing permission to do...

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 Daniel Howard