Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

components: this.components.map((component) => component.toJSON()) #9746

Closed
enkee0 opened this issue Aug 3, 2023 · 1 comment
Closed

components: this.components.map((component) => component.toJSON()) #9746

enkee0 opened this issue Aug 3, 2023 · 1 comment

Comments

@enkee0
Copy link

enkee0 commented Aug 3, 2023

Which package is this bug report for?

discord.js

Issue description

D:\db\node_modules@discordjs\builders\dist\index.js:1285
components: this.components.map((component) => component.toJSON())
^

TypeError: Cannot read properties of undefined (reading 'toJSON')
at D:\db\node_modules@discordjs\builders\dist\index.js:1285:64
at Array.map ()
at ActionRowBuilder.toJSON (D:\db\node_modules@discordjs\builders\dist\index.js:1285:35)
at D:\db\node_modules@discordjs\builders\dist\index.js:1374:64
at Array.map ()
at ModalBuilder.toJSON (D:\db\node_modules@discordjs\builders\dist\index.js:1374:35)
at ButtonInteraction.showModal (D:\db\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:256:46)
at Client. (D:\db\index.js:57:17)
at Client.emit (node:events:549:35)
at InteractionCreateAction.handle (D:\db\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)

Code sample

const {
  Client,
  GatewayIntentBits,
  Events,
  EmbedBuilder,
  ModalBuilder,
  TextInputBuilder,
  TextInputStyle,
  ActionRowBuilder,
} = require("discord.js");
require("dotenv").config();
const { token, databaseURL } = process.env;
const { readdirSync } = require("node:fs");

const client = new Client({
  intents: [GatewayIntentBits.Guilds],
});

readdirSync("./handlers").forEach((handler) => {
  require(`./handlers/${handler}`)(client);
});

// const { connect } = require("mongoose");
// connect(databaseURL, {}).then(() =>
//   console.log("the client is now connected to database")
// );

client.on(Events.InteractionCreate, (interaction) => {
  const name = interaction.fields?.getTextInputValue("name");
  const age = interaction.fields?.getTextInputValue("age");
  const about = interaction.fields?.getTextInputValue("about");
  const channel = client.channels.cache.get("1134924130421067959");
  const modal = new ModalBuilder().setCustomId("modal1").setTitle("test");

  const name1 = new TextInputBuilder()
    .setCustomId("name")
    .setLabel("اسمك")
    .setStyle(TextInputStyle.Short);

  const age1 = new TextInputBuilder()
    .setCustomId("age")
    .setLabel("عمرك")
    .setStyle(TextInputStyle.Short)
    .setMinLength(2)
    .setMaxLength(2);

  const about1 = new TextInputBuilder()
    .setCustomId("about")
    .setLabel("خبراتك")
    .setStyle(TextInputStyle.Paragraph);

  const frist = new ActionRowBuilder().addComponents(name);
  const frist1 = new ActionRowBuilder().addComponents(age);
  const frist2 = new ActionRowBuilder().addComponents(about);
  modal.addComponents(frist, frist1, frist2);
  if (interaction.customId == "confirm") {
    interaction.showModal(modal);
  }
});

client.login(token);

Versions

discord.js 14.11.0
node v18.4.0

Issue priority

Low (slightly annoying)

Which partials do you have configured?

Message

Which gateway intents are you subscribing to?

Not applicable

I have tested this issue on a development release

No response

@Jiralite
Copy link
Member

Jiralite commented Aug 3, 2023

If you're unsure about something, you should ask in the Discord server or create a new discussion as this issue tracker is only for bug reports and enhancement suggestions.

@Jiralite Jiralite closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants