Encountering an Invalid Form Body error (DiscordAPIError[50035]) while attempting to register my commands on Discord

After following the discord.js guide to create a suggest command using a basic command handler, I encountered an error when deploying my commands. Despite being new to DiscordJS, I have attempted to troubleshoot by adjusting my embeds.


    DiscordAPIError[50035]: Invalid Form Body
guild_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
    at SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:753:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:565:14)
    at async REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:999:22) {
  rawError: {
    code: 50035,
    errors: { guild_id: [Object] },
    message: 'Invalid Form Body'
  },
  code: 50035,
  status: 400,
  method: 'PUT',
  url: 'https://discord.com/api/v9/applications/991898175478714409/guilds/undefined/commands',
  requestBody: { files: undefined, json: [ [Object], [Object], [Object] ] }
}

Here is the code for my suggestion command:


    const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js');
const { suggestChannelID, suggestLogChannelID, suggestManageRoleID } = require('/home/container/config.json');

module.exports = {
  data : new SlashCommandBuilder()
    .setName('suggest')
    .addStringOption(option => option.setName('suggestion').setDescription('The feature you want to suggest').setRequired(true))
    .setDescription('Suggest a feature to be added to our platform(s)'),
  async execute(interaction) {
    var d = new Date();
    const suggestEmbed = new MessageEmbed()
      .setTitle('New Suggestion')
      .setDescription(interaction.options.getString('Suggestion'))
      .setFooter({ text: `Suggested by <@${interaction.member.id}> @ ` + d.toLocaleTimeString() + " GMT" })
    const row = new MessageActionRow()
      .addComponents(
        new MessageButton()
          .setCustomId('upvote')
          .setStyle('SUCCESS')
          .setLabel('Upvote'),
        new MessageButton()
          .setCustomId('downvote')
          .setStyle('DANGER')
          .setLabel('downvote'),
        new MessageButton()
          .setCustomId('accept')
          .setStyle('SUCCESS')
          .setLabel('Accept'),
        new MessageButton()
          .setCustomId('deny')
          .setStyle('DANGER')
          .setLabel('Deny'),
        new MessageButton()
          .setCustomId('remove')
          .setStyle('SECONDARY')
          .setLabel('Remove'),
      )
    interaction.member.guild.channels.cache.get(suggestChannelID).send({ embeds: [suggestEmbed], components: [row] });
    interaction.reply('Suggestion successfully sent!')
  }
}


Answer №1

Encountering a similar problem, I managed to resolve it by changing the file names of my command files (the filenames themselves, not just the command names inside) to ensure that none of them began with a capital letter.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Throwing an error in ExpressJS from a promise

I am facing an issue with my current ExpressJS-Application. I currently use regular functions to wrap different routes in the app, and if there is an error, I can easily use return next (err) to exit the function (return) and call the error handler (next ( ...

Executing code after finishing a fetch in Next.js

Here is the JavaScript code snippet under question: async function checkAuth() { console.log("3") await fetch(apiUrl+'/auth', { method: 'POST' }).then(response => response.json()).then(result => { ...

Locate the position of a substring within a Uint8Array

I'm working with a Uint8Array that contains the content of a PDF file. My goal is to locate a specific string within this array in order to insert additional content at that particular position. My current approach involves converting the Uint8Array ...

Repeating calls to the init() function within an AngularJS controller

Encountering an issue while developing an angularjs application. I have set up a controller and bound it in routeProvider with a function to initialize values like so: angular.module('app.Login', ['app.rpc','ngRoute']) ...

Perform fn(param1, param2) within a callback using AngularJS ng-click syntax

When using AngularJS (and likely in other frameworks as well), you have the ability to pass a function with parameters to ng-click like this: <div ng-click="myFunc(param)">Click Me</div> I am interested in achieving the same functionality by ...

Tips on maintaining the parent's scope in CoffeeScript while making an AJAX call

I need to iterate through an object in CoffeeScript and make an AJAX call for each item in the object using jQuery. However, I'm facing an issue with losing the reference to the initial context in the callback function of the AJAX call. The context al ...

Interactive hexagon shape with dynamic image content on click using a combination of CSS, HTML,

As a beginner in CSS, HTML, and JavaScript, I came across a code snippet to create a pattern of hexagons with images (refer to the first code below). My goal is to change the image displayed on a clicked hexagon to another picture (see second code). First ...

When anticipating the result of an asynchronous function, you may encounter an error message similar to "Cannot find name 'await'."

// Encountering an error - 'await' is not recognized as a valid name.ts(2304) let someVariable = await (async ():someType => { // I require the use of await here, hence the need for async return someValue; })(); // The code below works ...

Directive Template with Dynamic Fields (AngularJS)

I am interested in creating a custom directive that can bind to any object, allowing me to specify the field used in the template for display. Previously, I was limited to using {{item.Name}}, but now I want the flexibility to define the display field. Cu ...

point to a member of a JSON (Javascript) data structure

Can you show me how to access an element from a JSON object in Javascript? For example: alert(homes.Agents[1].name); <script> var homes = [ { "Agents" : { "name" : "Bob Barker", "name" : "Mona Mayflower" }, "Listi ...

Leveraging scanner-js within an Angular2 environment

Exploring ways to incorporate Scanner-JS into my Angular2 project, a tool I discovered while tinkering with the framework. Being a novice in Angular2, this question might be elementary for some. I successfully installed scanner-js via npm npm install sc ...

Ways to select the initial 10 rows, final 3 rows, and middle 2 rows using Javascript

As a newcomer to Javascript, I have a couple of questions: 1) How can I retrieve the first 10 rows, the last 3 rows, and the 2 rows in the center using the code var firstTable = $('#aaa table').eq(0); 2) Is there a way to create and assign new ...

Nested v-for problem confusion

I am encountering an issue with my code and I'm wondering if anyone can help me troubleshoot it. The problem is that whenever I click on the content of one panel, all panel contents with the same index expand or collapse instead of just the one I clic ...

leveraging a Nuxt plugin and saving it in middleware

My goal is to create a middleware that validates the authentication and entitlement of users. The authentication details are retrieved from my store: //store/index.js const state = () => ({ auth: { isLoggedIn: false // more properties here } ...

Calculate the total of an array with the help of the angular forEach function

function dialogController(generate, $scope) { $scope.profiles = generate.get_keys('::role'); $scope.content = {}; $scope.options = []; $scope.servers = {}; $scope.subs = {}; $scope.discountList = {}; $sco ...

Crafting artistic shapes using the Canny Edge Detection technique on Canvas

Can someone provide some guidance on using Canny Edge Detection to generate shapes in Canvas? ...

Encountering a console error: Prop type validation failed for the `Rating` component with the message that the prop `value` is required but is currently `undefined`

I am encountering a proptype error which is causing an issue with the URL display on my Chrome browser. Instead of showing a proper address, I am seeing the URL as undefined like this: http://localhost:3000/order/undefined Instead of undefined, I should h ...

Issue with the URL associated with the CSS file

As a PHP beginner, I'm having trouble linking to the CSS file using the provided codes. Can anyone help me troubleshoot what's wrong with my code? The issue seems to be in the following snippet from header.php: <html lang="en"> <head&g ...

Is it possible for this solution to be compatible with IE7 and IE6?

Is there a way to enhance this solution for compatibility with IE6 and IE7? http://jsfiddle.net/kirkstrobeck/sDh7s/1/ Referenced from this discussion After some research, I have come up with a practical solution. I've converted it into a new func ...

What is the best way to adjust the color of a button element?

I've been troubleshooting the mouseover function of my JavaScript button object. The goal is to have a function call (specifically show()) within the object that detects the mouseover event and changes the button's color to grey. I suspect that t ...