我对discord.js 斜杠命令有疑问。
正如您在我的代码中看到的,我将名称设置为“Name”和“Age”,所以我不明白问题是什么。
这是我的错误:
error: (node:16004) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
options[0].name: Command name is invalid
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
const Discord = require('discord.js');
require("dotenv").config();
const client = new Discord.Client();
client.on('ready', async () => {
console.log(`Logged in as ${client.user.tag}!`);
const getApp = (guildid) => {
const app = client.api.applications(client.user.id);
if(guildid){
app.guilds(guildid);
}
return app;
}
await getApp("842486032842358784").commands.post({
data: {
name: 'embed',
description: 'Displays embed',
options: [
{
name: 'Name',
description: 'Your Name',
required: true,
type: 3
},
{
name: 'Age',
description: 'Your Age', …Run Code Online (Sandbox Code Playgroud)