#BASE_TYPE_REQUIRED... what?

26 messages · Page 1 of 1 (latest)

sleek ginkgo
#
const { SlashCommandBuilder } = require('@discordjs/builders')

module.exports = {
    data: new SlashCommandBuilder()
        .setName('create-ticket')
        .setDescription('Create a Support Ticket!'),
    async execute(interaction) {
        const ticketName = `ticket-${interaction.user.id}`
        if (!interaction.channel.id == process.env.TICKET_CHANNEL) {
            return
        } else if ((interaction.guild.channels.cache.find(c => c.name.toLowerCase() === ticketName.toLowerCase()))) {
            interaction.reply(`ERROR: You already have an outstanding ticket`)
        } else {
            interaction.guild.channels.create(ticketName, { type: 'text', }).then((chan) => {
                console.log(chan)
            })
        }
    }
}

(hold for error and question)

shut torrentBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

sleek ginkgo
#

Bruh

#

One sec

#

Error:

> [email protected] start
> node app.js

/home/.../wee6-v4/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:287
        throw new DiscordAPIError.DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
              ^

DiscordAPIError[50035]: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
    at SequentialHandler.runRequest (/home/.../wee6-v4/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:287:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async SequentialHandler.queueRequest (/home/.../wee6-v4/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:99:14)
    at async REST.request (/home/.../wee6-v4/node_modules/@discordjs/rest/dist/lib/REST.cjs:52:22)
    at async GuildChannelManager.create (/home/jramos/wee6-v4/node_modules/discord.js/src/managers/GuildChannelManager.js:145:18) {
  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/1002293348033380403/channels',
  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
    }
  }
}

Node.js v17.9.0
#

I'm using version 14.0.3 and node 17.9.0

broken estuary
#

<GuildChannelManager>.create() takes a single object param now (with name as an option)
also the type takes a number, for which you can use the ChannelType enum (ChannelType.GuildText)

sleek ginkgo
#

So if I wanted it to create a guild text channel, I'd need to specify some number instead of type: text?

broken estuary
#

yes, for which you can use ChannelType.GuildText

sleek ginkgo
#

I'm not sure I follow. That's not a number.

broken estuary
#

it's an enum that represents a number 🙂

#

you can import ChannelType from discord.js 🙂

sleek ginkgo
#

Oh! I see. Lemme try that.

#

Hmm... no dice.

const { SlashCommandBuilder } = require('@discordjs/builders')
const { ChannelType } = require('discord.js')

module.exports = {
    data: new SlashCommandBuilder()
        .setName('create-ticket')
        .setDescription('Create a Support Ticket!'),
    async execute(interaction) {
        const ticketName = `ticket-${interaction.user.id}`
        if (!interaction.channel.id == process.env.TICKET_CHANNEL) {
            return
        } else if ((interaction.guild.channels.cache.find(c => c.name.toLowerCase() === ticketName.toLowerCase()))) {
            interaction.reply(`ERROR: You already have an outstanding ticket`)
        } else {
            interaction.guild.channels.create(ticketName, { type: ChannelType.GuildText, }).then((chan) => {
                console.log(chan)
            })
        }
    }
}

I still get the same error.

broken estuary
sleek ginkgo
#

I don't know what that's supposed to mean

shut torrentBOT
broken estuary
#

there's a code example here

#

it only takes 1 param, which should be an object
not 2 params, where the first is a string

sleek ginkgo
#

Oh, so just move the name param into the object

broken estuary
#

ye

sleek ginkgo
#

Alright, one sec

#

Blimey... that was throwing me for a loop. Thanks for the help.

broken estuary
#

👍

sleek ginkgo
#
const channelCount = (await guild.channels.fetch()).filter(
  (channel) => channel.type !== ChannelType.GuildCategory
).size;```
is this correct?
#

oh fck