I'm trying the new Discord Modals feature and it's not working

I’m trying the new Discord Modals feature and I’m getting this error:

/app/commands/feedback.js:18
          .setRequired(true)
           ^
TypeError: (intermediate value).setCustomId(...).setPlaceholder(...).setRequired is not a function
at Command.callback [as _callback] (/app/commands/feedback.js:18:12)
    at SlashCommands.invokeCommand (/rbd/pnpm-volume/b8c32a91-943c-4620-a65f-06ac83284865/node_modules/wokcommands/dist/SlashCommands.js:155:37)
    at Client.<anonymous> (/rbd/pnpm-volume/b8c32a91-943c-4620-a65f-06ac83284865/node_modules/wokcommands/dist/SlashCommands.js:74:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I use the Worn Off Keys command handler, and here is my code.

server.js (main file)

const DiscordJS = require("discord.js");
const discordModals = require("discord-modals");
const WOKCommands = require("wokcommands");
const path = require("path");
const dotenv = require("dotenv/config");

const Levels = require("discord-xp");

var ownerId = "874730179468079159";
var notifications = "987099459026554940";

function sendNotification(user, category, msg) {
  client.channels.cache.get(notifications).send({
    embeds: [
      {
        color: "5352ed",
        author: {
          name: category,
          icon_url: user.displayAvatarURL({ format: "png" }),
        },
        description: msg,
      },
    ],
    content: `<@${user.id}>, you have a new server notification:`,
  });
}

var token = "CENSORED";
var pass = "CENSORED";

Levels.setURL(
  `mongodb+srv://discordbot:${pass}@bot.haumy.mongodb.net/myFirstDatabase?retryWrites=true&w=majority`
);

const { Intents } = DiscordJS;

const client = new DiscordJS.Client({
  // These intents are recommended for the built in help menu
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MESSAGES,
    Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
    Intents.FLAGS.GUILD_VOICE_STATES,
    Intents.FLAGS.GUILD_MEMBERS,
  ],
});

client.on("ready", () => {
  
  const dbOptions = {
    // These are the default values
    keepAlive: true,
  };

  const wok = new WOKCommands(client, {
    // The name of the local folder for your command files
    commandsDir: path.join(__dirname, "commands"),
    dbOptions,
    mongoUri: `mongodb+srv://discordbot:${pass}@bot.haumy.mongodb.net/myFirstDatabase?retryWrites=true&w=majority`,
    testServers: ["749767042785083451"],
    botOwners: ["874730179468079159"],
  });

  const { commandHandler } = wok;
  
  discordModals(client);
});

commands/feedback.js (This is the command file, I’m making a feedback command)

const { Modal, TextInputComponent, SelectMenuComponent, showModal } = require("discord-modals");

module.exports = {
  category: "Other",
  description: "Give us feedback.",

  slash: true,
  testOnly: true,

  callback: ({ interaction, client }) => {
    const modal = new Modal()
      .setCustomId("feedback-modal")
      .setTitle("Feedback Form")
      .addComponents(
        new SelectMenuComponent()
          .setCustomId("Q1")
          .setPlaceholder("How did you find this Discord server?")
          .setRequired(true)
          .addOptions(
            {
              label: "disboard.org",
              description: "This is a Discord server list website for people to find Discord servers or add their own Discord server to the website.",
              value: "disboard.org",
              emoji: "💻"
            },
            {
              label: "top.gg",
              description: "This is a Discord server list website for people to find Discord servers or add their own Discord server to the website.",
              value: "top.gg",
              emoji: "💻"
            },
            {
              label: "TikoGrant's YouTube Channel",
              description: "TikoGrant is the owner of this server who has a YouTube channel. This Discord server can be found on TikoGrant's YouTube channel. https://youtube.com/tikogrant",
              value: "YouTube",
              emoji: "📽️"
            },
            {
              label: "TikoGrant's Website/Kitty Paradise Website",
              description: "The owner of this server has 2 websites that lead to this Discord server.",
              value: "Web",
              emoji: "💻"
            },
            {
              label: "I forgot/I don't know",
              description: "If you forgot or don't know how you joined, pick this option.",
              value: "Forgot or Doesn't Know",
              emoji: "❔"
            },
            {
              label: "Other Way That's Not Listed",
              description: "If the way you joined isn't listed in this list, pick this option.",
              value: "Other",
              emoji: "❔"
            }
          ),
        
        new TextInputComponent()
          .setCustomId("Q2")
          .setPlaceholder("Why did you choose to join this server?")
          .setStyle("LONG")
          .setRequired(true),
        
        new TextInputComponent()
          .setCustomId("Q3")
          .setPlaceholder("What do you feel positive about in this server? This could be a specific channel, role, bot, feature, or anything you like in the server.")
          .setStyle("SHORT")
          .setRequired(true),
        
        new TextInputComponent()
          .setCustomId("Q4")
          .setPlaceholder("What do you feel negitive about in this server? This could be a specific channel, role, bot, feature or anything you don't like in the server.")
          .setStyle("SHORT")
          .setRequired(true),
        
        new TextInputComponent()
          .setCustomId("Q5")
          .setPlaceholder("What suggestions do you have for this server? It could be anything. Please give us at least 1 valid suggestion for this server.")
          .setStyle("SHORT")
          .setRequired(true)
      )
    
    showModal(modal, {
      client: client,
      interaction: interaction
    });
  },
};

Thank you to anyone who can help me. Thanks!

I figured out that it works without the SelectMenuComponent, but I still need help fixing this problem. It states it in the discord-modals documentation (npm website).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.