小编emr*_*ras的帖子

Discord.js 斜线命令名称无效

我对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)

javascript node.js discord discord.js

0
推荐指数
1
解决办法
7180
查看次数

标签 统计

discord ×1

discord.js ×1

javascript ×1

node.js ×1