首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不一致JS:部署命令

不一致JS:部署命令
EN

Stack Overflow用户
提问于 2021-10-28 00:23:42
回答 1查看 912关注 0票数 0

我正在使用discord.js v13。我已经成功地创建了一个带有作用域bot和application.commands的机器人,并成功地将它添加到我的服务器上的一个通道中。现在,我按照tutorial注册斜杠命令。我创建了一个包含以下内容的文件deploy-commands.js:

代码语言:javascript
运行
复制
    const { SlashCommandBuilder } = require('@discordjs/builders');
    const { REST } = require('@discordjs/rest');
    const { Routes } = require('discord-api-types/v9');
    const { clientId, guildId, token } = require('./config.json');
    
    const commands = [
        new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
        new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
        new SlashCommandBuilder().setName('user').setDescription('Replies with user info!'),
    ]
        .map(command => command.toJSON());
    
    const rest = new REST({ version: '9' }).setToken(token);
    
    rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
        .then(() => console.log('Successfully registered application commands.'))
        .catch(console.error);

然后我运行命令node deploy-commands.js,我得到了错误:

代码语言:javascript
运行
复制
    DiscordAPIError[50001]: Missing Access
        at SequentialHandler.runRequest (/home/evalenzuela/apps/discord-aurasix/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:198:23)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async SequentialHandler.queueRequest (/home/evalenzuela/apps/discord-aurasix/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.js:99:20) {
      rawError: { message: 'Missing Access', code: 50001 },
      code: 50001,
      status: 403,
      method: 'put',
      url: 'https://discord.com/api/v9/applications/901217590259617813/guilds/901235476399280138/commands'
}

我在互联网上查看了很多信息,但找不到解决方案。我已经三次检查了clientId、guildId和应用程序令牌。

EN

Stack Overflow用户

发布于 2021-11-01 15:11:35

除了佩德罗的评论,来自Trying to register commands: DiscordAPIError[50001]: Missing Access的评论:“你是否确保在discord开发者门户中你的机器人的OAuth2设置的范围部分选中了'applications.commands‘作用域?”

您提到您重新创建了应用程序和机器人,但没有验证您是否正确设置了application.commands作用域权限。这可能是你的问题。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69746918

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档