Pieter Burger
Pieter Burger

Reputation: 161

DiscordAPIError[undefined]: No Description

I am currently building a music bot for my Discord channel, but I keep getting an error when trying to load the commands. This error has so far appeared on all the bots that I am trying to build even the most basic. Here is the example code that I used straight off of the Discord Documentation:

const { REST, Routes } = require("discord.js");
const { Client, GatewayIntentBits } = require("discord.js");
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

const CLIENT_ID = "ID";

const TOKEN =
  "token";

const commands = [
  {
    name: "ping",
    description: "Replies with Pong!",
  },
];

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

(async () => {
  try {
    await rest.put(Routes.applicationCommands(CLIENT_ID), {
      headers: { authorization: `Bot ${TOKEN}` },
      body: commands,
    });

  } catch (error) {
    console.error(error);
  }
})();

client.on("ready", () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on("interactionCreate", async (interaction) => {
  if (!interaction.isChatInputCommand()) return;

  if (interaction.commandName === "ping") {
    await interaction.reply("Pong!");
  }
});

client.login(TOKEN);

I am getting the following error:

DiscordAPIError[undefined]: No Description
    at SequentialHandler.runRequest (...\MusicBot\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:293:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (...\MusicBot\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:99:14)
    at async REST.request (...\React\MusicBot\node_modules\@discordjs\rest\dist\lib\REST.cjs:52:22)
    at async ...\MusicBot\index.js:24:5 {
  rawError: Uint8Array(155) [
     60, 104, 116, 109, 108,  62,  13,  10,  60, 104, 101,  97,
    100,  62,  60, 116, 105, 116, 108, 101,  62,  52,  48,  48,
     32,  66,  97, 100,  32,  82, 101, 113, 117, 101, 115, 116,
     60,  47, 116, 105, 116, 108, 101,  62,  60,  47, 104, 101,
     97, 100,  62,  13,  10,  60,  98, 111, 100, 121,  62,  13,
     10,  60,  99, 101, 110, 116, 101, 114,  62,  60, 104,  49,
     62,  52,  48,  48,  32,  66,  97, 100,  32,  82, 101, 113,
    117, 101, 115, 116,  60,  47, 104,  49,  62,  60,  47,  99,
    101, 110, 116, 101,
    ... 55 more items
  ],
  code: undefined,
  status: 400,
  method: 'PUT',
  url: 'https://discord.com/api/v9/applications/1021797370285010954/commands',
  requestBody: { files: undefined, json: undefined }
}

Upvotes: 1

Views: 491

Answers (1)

Pieter Burger
Pieter Burger

Reputation: 161

So seems the solution was by removing the headers:

headers: { authorization: `Bot ${TOKEN}` },

from the payload and clearing my cache with npm cache clean –force , my issue was resolved after I did this.

Upvotes: 1

Related Questions