You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord.js注册斜杠命令时遇DiscordAPIError[50035]报错求助

问题解决:Discord.js斜杠命令注册提示description必填的问题

你的问题核心是字段名拼写错误:你在命令对象里写的是descripton(少了一个字母i),而Discord API要求的必填字段是description,API识别不到错误的字段名,所以判定description字段缺失,返回了50035错误。

修改后的代码如下:

const { REST, Routes} = require('discord.js')
require('dotenv').config();

const commands = [
    {
        name:'rank',
        description: ' Show rank of user on crew3', // 修正拼写错误
    },
];

const rest = new REST({version: '10'}).setToken(process.env.TOKEN);

(async() => {
    try {
        console.log('Registering slash commands');

        await rest.put(
            Routes.applicationGuildCommands(process.env.BOT_ID, process.env.GUILD_ID),
            {body: commands}
        );
        console.log('Slash commands registered successfully');
    } catch (error) {
        console.log(`${error}`);
    }
})();

只需将descripton改为正确的description,重新运行注册脚本即可解决这个问题。

内容的提问来源于stack exchange,提问作者Grapuco

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 02:55:08