首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >DiscordAPIError[50035]:无效表单Body 5[APPLICATION_COMMANDS_DUPLICATE_NAME]:应用程序命令名必须是唯一的

DiscordAPIError[50035]:无效表单Body 5[APPLICATION_COMMANDS_DUPLICATE_NAME]:应用程序命令名必须是唯一的
EN

Stack Overflow用户
提问于 2022-09-23 13:57:30
回答 2查看 66关注 0票数 0

这是我的index.js

代码语言:javascript
运行
复制
const LOAD_SLASH = process.argv[2] == "load"

const CLIENT_ID = "981858607362629663"
const GUILD_ID = "970702726348546078"

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildVoiceStates
    ]
})

client.slashcommands = new Discord.Collection()
client.player = new Player(client, {
    ytdlOptions: {
        quality: "highestaudio",
        highWaterMark: 1 << 25
    }
})

let commands = []

const slashFiles = fs.readdirSync("./slash").filter(file => file.endsWith(".js"))
for (const file of slashFiles){
    const slashcmd = require(`./slash/${file}`)
    client.slashcommands.set(slashcmd.data.name, slashcmd)
    if (LOAD_SLASH) commands.push(slashcmd.data.toJSON())
}

运行node index.js load后,会收到以下错误:

DiscordAPIError[50035]: Invalid Form Body 5[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names must be unique at SequentialHandler.runRequest

我已经尝试卸载和重新安装discord.js,但我仍然在经历这个错误,我真的想要一些帮助!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-09-23 18:02:14

文件中的某个地方有一个重复的命令名。试着用下面的代码片段找到它:

代码语言:javascript
运行
复制
const slashFiles = fs.readdirSync("./slash").filter(file => file.endsWith(".js"))
for (const file of slashFiles){
    const slashcmd = require(`./slash/${file}`)
    console.log(slashcmd.data.name)
}

找到记录了两次的命令名,然后相应地编辑命令文件。

票数 0
EN

Stack Overflow用户

发布于 2022-09-24 14:15:25

在其中一个文件中,您使用另一个文件复制name

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

https://stackoverflow.com/questions/73828887

复制
相关文章

相似问题

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