简体   繁体   English

DiscordAPIError:运行 discord.js 机器人命令时缺少访问权限

[英]DiscordAPIError: Missing Access when running discord.js bot command

When I start the bot and use my "ping" command I get this error:当我启动机器人并使用我的“ping”命令时,我收到此错误:

    js:350
          throw new DiscordAPIError(data, res.status, request);
                ^
    
    DiscordAPIError: Missing Access
        at RequestHandler.execute (C:\Users\LiamS\OneDrive\Documenten\Chill Lounge\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\LiamS\OneDrive\Documenten\Chill Lounge\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
        at async GuildApplicationCommandManager.set (C:\Users\LiamS\OneDrive\Documenten\Chill Lounge\node_modules\discord.js\src\managers\ApplicationCommandManager.js:156:18)
        at async Client.<anonymous> (C:\Users\LiamS\OneDrive\Documenten\Chill Lounge\handler\index.js:45:9) {
      method: 'put',
      path: '/applications/996753512807530637/guilds/996381328255750206/commands',
      code: 50001,
      httpStatus: 403,
      requestData: {
        json: [
          {
            name: 'ping',
            name_localizations: undefined,
            description: 'returns websocket ping',
            description_localizations: undefined,
            type: 1,
            options: undefined,
            default_permission: undefined
          }
        ],
        files: []
      }
    }

Can someone please help me?有人可以帮帮我吗?

It's a guess, because you didn't post any code, but I'm assuming that you are trying to register "ping" slash command on a specific guild (aka "server"), and the error is likely because your bot is lacking application.commands scope on that guild and therefore can't register that command.这是一个猜测,因为您没有发布任何代码,但我假设您正在尝试在特定公会(又名“服务器”)上注册“ping”斜杠命令,并且该错误可能是因为您的机器人缺少该行会的application.commands范围,因此无法注册该命令。

So try re-inviting the bot to that guild with application.commands scope included and see if it helps.因此,尝试重新邀请机器人加入包含application.commands范围的公会,看看是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM