#Invalid form body

1 messages · Page 1 of 1 (latest)

carmine sedge
#

.

#

DiscordAPIError[50035]: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
    at handleErrors (C:\Users\tom\node_modules\@discordjs\rest\dist\index.js:640:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (C:\Users\tom\node_modules\@discordjs\rest\dist\index.js:1021:23)
    at async SequentialHandler.queueRequest (C:\Users\tom\node_modules\@discordjs\rest\dist\index.js:862:14)
    at async REST.request (C:\Users\tom\node_modules\@discordjs\rest\dist\index.js:1387:22)
    at async GuildChannelManager.create (C:\Users\tom\node_modules\discord.js\src\managers\GuildChannelManager.js:170:18) {
  requestBody: {
    files: undefined,
    json: {
      name: undefined,
      topic: undefined,
      type: undefined,
      nsfw: undefined,
      bitrate: undefined,
      user_limit: undefined,
      parent_id: undefined,
      position: undefined,
      permission_overwrites: undefined,
      rate_limit_per_user: undefined,
      rtc_region: undefined,
      video_quality_mode: undefined,
      available_tags: undefined,
      default_reaction_emoji: undefined,
      default_auto_archive_duration: undefined,
      default_sort_order: undefined,
      default_forum_layout: undefined
    }
  },
  rawError: {
    code: 50035,
    errors: {
      name: {
        _errors: [
          {
            code: 'BASE_TYPE_REQUIRED',
            message: 'This field is required'
          }
        ]
      }
    },
    message: 'Invalid Form Body'
  },
  code: 50035,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/guilds/1112842609161932941/channels'
}
#

Any idea where this error occurs? I’m very bad at debugging invalid body forms

marsh beacon
#

every property is undefined

#

you never set any name, description, etc

carmine sedge
#

To what

#

That’s my question

marsh beacon
#

a channel

carmine sedge
#

2 sec I’ll post my channel creation code

#

function createChannel(name, type, parent) {
        interaction.guild.channels.create(name, {
            type: type,
            parent: parent,
            permissionOverwrites: [
                {
                    id: interaction.guild.roles.everyone.id,
                    deny: [PermissionsBitField.Flags.ViewChannel]
                },
                {
                    id: interaction.user.id,
                    allow: [PermissionsBitField.Flags.ViewChannel, PermissionsBitField.Flags.AttachFiles,PermissionsBitField.Flags.SendMessages, PermissionsBitField.Flags.AddReactions, PermissionsBitField.Flags.AttachFiles, PermissionsBitField.Flags.EmbedLinks, PermissionsBitField.Flags.ReadMessageHistory, PermissionsBitField.Flags.UseExternalEmojis, PermissionsBitField.Flags.Connect, PermissionsBitField.Flags.Speak, PermissionsBitField.Flags.Stream]

                    
                }

            ]
        })
    }

createChannel(`${button}-${interaction.user.username}`, ChannelType.GuildText, '1112842609161932946')```
marsh beacon
#

wherever you call your method you're not passing in any of the params

carmine sedge
#

All variables are defined, this is just a snippet of all channel related creations

marsh beacon
#

none of the variables are defined, not even your overwrites

rain cradle
#

the name goes inside the object

marsh beacon
#

oh yep thats it indeed

thin burrowBOT
marsh beacon
#

always confuse .edit and .create

rain cradle
#

yup it happens

carmine sedge
rain cradle
#

the name option goes inside the object

carmine sedge
#

Oh inside the create?

rain cradle
#

yes

rain cradle
marsh beacon
#

.create({name: "", ...})

carmine sedge
#

As such correct

marsh beacon
#

yep

carmine sedge
#

Yeah I was reading the doc, copilot might of taken it a bit weird dD

#

Time to test

#

It worked !!!!

#

Tyvm

#

I’m making a fully customizable ticket system without webpanel. It’s rough lmao but I’m about 75% of the way done

marsh beacon
#

formbodies arent really difficult to debug. If you see undefined on every property that should already alert you. the url can also be used to see what you are doing, if you POST a request to /channels, it has something to do with creating a channel

carmine sedge
#

Just need to set up the database portion and then get the messages to properly submit per button

#

😉