Error: Expected the value to be a string or number

const {
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
MessageFlags,
TextDisplayBuilder,
ContainerBuilder,
SeparatorBuilder,
SeparatorSpacingSize,
MediaGalleryBuilder,
} = require("discord.js");
const open_questions = require("../../actions/button/whitelist/open_questions");

const whitelistSetup = async (interaction, options) => {
console.log("Whitelist setup started.");

const mediaGallery = new MediaGalleryBuilder()
.addItems([
{
url: "https://r2.fivemanage.com/c5R8i5l3IaIkvuFXePEUX/7f158542f31fd37a120cd08a7cf1493a_720w.gif",
alt: "Reckon City Whitelist",
type: "image"
}
]);


const applyButton = new ButtonBuilder()
.setCustomId(String(open_questions.id))
.setLabel("Apply Whitelist")
.setStyle(ButtonStyle.Secondary);

if (open_questions.emoji) {
applyButton.setEmoji(open_questions.emoji);
} else {
applyButton.setEmoji({ name: 'verify_green', id: '1376781430075686983' });
}

const actionRow = new ActionRowBuilder()
.addComponents(applyButton);

const container_component = new ContainerBuilder()
.setAccentColor(null)
.addMediaGalleryComponents(mediaGallery)
.addTextDisplayComponents(
new TextDisplayBuilder("# RECKON CITY WHITELIST")
)
.addSeparatorComponents(
new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Medium)
)
.addTextDisplayComponents(
new TextDisplayBuilder(
"## Apply Now For Whitelist\n\n" +
"- Interview : - Whitelist Interviews are available 12x7\n\n" +
"- Availability : - We're usually available peak time : 10.00 AM to 11.00 PM\n\n"
)
)
.addActionRowComponents(actionRow)
.addTextDisplayComponents(
new TextDisplayBuilder("### RECKON CITY Management")
);

try {
await interaction.channel.send({
components: [container_component],
flags: MessageFlags.IsComponentV2,
});

await interaction.editReply({
content: "✅ Whitelist setup completed.",
flags: MessageFlags.Ephemeral,
});
} catch (error) {
console.error("Error in whitelist setup:", error);
await interaction.editReply({
content: "❌ Failed to setup whitelist. Please check the logs.",
flags: MessageFlags.Ephemeral,
});
}
};

module.exports = {
command: false,
execute: whitelistSetup,
};
const {
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
MessageFlags,
TextDisplayBuilder,
ContainerBuilder,
SeparatorBuilder,
SeparatorSpacingSize,
MediaGalleryBuilder,
} = require("discord.js");
const open_questions = require("../../actions/button/whitelist/open_questions");

const whitelistSetup = async (interaction, options) => {
console.log("Whitelist setup started.");

const mediaGallery = new MediaGalleryBuilder()
.addItems([
{
url: "https://r2.fivemanage.com/c5R8i5l3IaIkvuFXePEUX/7f158542f31fd37a120cd08a7cf1493a_720w.gif",
alt: "Reckon City Whitelist",
type: "image"
}
]);


const applyButton = new ButtonBuilder()
.setCustomId(String(open_questions.id))
.setLabel("Apply Whitelist")
.setStyle(ButtonStyle.Secondary);

if (open_questions.emoji) {
applyButton.setEmoji(open_questions.emoji);
} else {
applyButton.setEmoji({ name: 'verify_green', id: '1376781430075686983' });
}

const actionRow = new ActionRowBuilder()
.addComponents(applyButton);

const container_component = new ContainerBuilder()
.setAccentColor(null)
.addMediaGalleryComponents(mediaGallery)
.addTextDisplayComponents(
new TextDisplayBuilder("# RECKON CITY WHITELIST")
)
.addSeparatorComponents(
new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Medium)
)
.addTextDisplayComponents(
new TextDisplayBuilder(
"## Apply Now For Whitelist\n\n" +
"- Interview : - Whitelist Interviews are available 12x7\n\n" +
"- Availability : - We're usually available peak time : 10.00 AM to 11.00 PM\n\n"
)
)
.addActionRowComponents(actionRow)
.addTextDisplayComponents(
new TextDisplayBuilder("### RECKON CITY Management")
);

try {
await interaction.channel.send({
components: [container_component],
flags: MessageFlags.IsComponentV2,
});

await interaction.editReply({
content: "✅ Whitelist setup completed.",
flags: MessageFlags.Ephemeral,
});
} catch (error) {
console.error("Error in whitelist setup:", error);
await interaction.editReply({
content: "❌ Failed to setup whitelist. Please check the logs.",
flags: MessageFlags.Ephemeral,
});
}
};

module.exports = {
command: false,
execute: whitelistSetup,
};
8 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
FaFaa
FaFaaOP6mo ago
const {
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
MessageFlags,
TextDisplayBuilder,
ContainerBuilder,
SeparatorBuilder,
SeparatorSpacingSize,
MediaGalleryBuilder,
} = require("discord.js");
const open_questions = require("../../actions/button/whitelist/open_questions");

const whitelistSetup = async (interaction, options) => {
console.log("Whitelist setup started.");

const mediaGallery = new MediaGalleryBuilder()
.addItems([
{
url: "https://r2.fivemanage.com/c5R8i5l3IaIkvuFXePEUX/7f158542f31fd37a120cd08a7cf1493a_720w.gif",
alt: "Reckon City Whitelist",
type: "image"
}
]);


const applyButton = new ButtonBuilder()
.setCustomId(String(open_questions.id))
.setLabel("Apply Whitelist")
.setStyle(ButtonStyle.Secondary);

if (open_questions.emoji) {
applyButton.setEmoji(open_questions.emoji);
} else {
applyButton.setEmoji({ name: 'verify_green', id: '1376781430075686983' });
}

const actionRow = new ActionRowBuilder()
.addComponents(applyButton);

const container_component = new ContainerBuilder()
.setAccentColor(null)
.addMediaGalleryComponents(mediaGallery)
.addTextDisplayComponents(
new TextDisplayBuilder("# RECKON CITY WHITELIST")
)
.addSeparatorComponents(
new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Medium)
)
.addTextDisplayComponents(
new TextDisplayBuilder(
"## Apply Now For Whitelist\n\n" +
"- Interview : - Whitelist Interviews are available 12x7\n\n" +
"- Availability : - We're usually available peak time : 10.00 AM to 11.00 PM\n\n"
)
)
.addActionRowComponents(actionRow)
.addTextDisplayComponents(
new TextDisplayBuilder("### RECKON CITY Management")
);

try {
await interaction.channel.send({
components: [container_component],
flags: MessageFlags.IsComponentV2,
});

await interaction.editReply({
content: "✅ Whitelist setup completed.",
flags: MessageFlags.Ephemeral,
});
} catch (error) {
console.error("Error in whitelist setup:", error);
await interaction.editReply({
content: "❌ Failed to setup whitelist. Please check the logs.",
flags: MessageFlags.Ephemeral,
});
}
};

module.exports = {
command: false,
execute: whitelistSetup,
};
const {
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
MessageFlags,
TextDisplayBuilder,
ContainerBuilder,
SeparatorBuilder,
SeparatorSpacingSize,
MediaGalleryBuilder,
} = require("discord.js");
const open_questions = require("../../actions/button/whitelist/open_questions");

const whitelistSetup = async (interaction, options) => {
console.log("Whitelist setup started.");

const mediaGallery = new MediaGalleryBuilder()
.addItems([
{
url: "https://r2.fivemanage.com/c5R8i5l3IaIkvuFXePEUX/7f158542f31fd37a120cd08a7cf1493a_720w.gif",
alt: "Reckon City Whitelist",
type: "image"
}
]);


const applyButton = new ButtonBuilder()
.setCustomId(String(open_questions.id))
.setLabel("Apply Whitelist")
.setStyle(ButtonStyle.Secondary);

if (open_questions.emoji) {
applyButton.setEmoji(open_questions.emoji);
} else {
applyButton.setEmoji({ name: 'verify_green', id: '1376781430075686983' });
}

const actionRow = new ActionRowBuilder()
.addComponents(applyButton);

const container_component = new ContainerBuilder()
.setAccentColor(null)
.addMediaGalleryComponents(mediaGallery)
.addTextDisplayComponents(
new TextDisplayBuilder("# RECKON CITY WHITELIST")
)
.addSeparatorComponents(
new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Medium)
)
.addTextDisplayComponents(
new TextDisplayBuilder(
"## Apply Now For Whitelist\n\n" +
"- Interview : - Whitelist Interviews are available 12x7\n\n" +
"- Availability : - We're usually available peak time : 10.00 AM to 11.00 PM\n\n"
)
)
.addActionRowComponents(actionRow)
.addTextDisplayComponents(
new TextDisplayBuilder("### RECKON CITY Management")
);

try {
await interaction.channel.send({
components: [container_component],
flags: MessageFlags.IsComponentV2,
});

await interaction.editReply({
content: "✅ Whitelist setup completed.",
flags: MessageFlags.Ephemeral,
});
} catch (error) {
console.error("Error in whitelist setup:", error);
await interaction.editReply({
content: "❌ Failed to setup whitelist. Please check the logs.",
flags: MessageFlags.Ephemeral,
});
}
};

module.exports = {
command: false,
execute: whitelistSetup,
};
Getting the Error: Error executing command setup: Error: Expected the value to be a string or number [DISCORD ERROR] Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred. at ChatInputCommandInteraction.reply (/home/container/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:163:46) at Object.execute (/home/container/handlers/command.js:29:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'InteractionAlreadyReplied' }
treble/luna
treble/luna6mo ago
please dont stringify your errors it makes them useless and it looks like your code and error dont match
FaFaa
FaFaaOP6mo ago
done
treble/luna
treble/luna6mo ago
not really if you stringify the error like you do, it gets rid of the stack though im pretty sure a TextDisplayBuilder's constructor does not take a string
FaFaa
FaFaaOP6mo ago
const {
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
MessageFlags,
TextDisplayBuilder,
ContainerBuilder,
SeparatorBuilder,
SeparatorSpacingSize,
MediaGalleryBuilder,
} = require("discord.js");
const open_questions = require("../../actions/button/whitelist/open_questions");

const whitelistSetup = async (interaction, options) => {
console.log("Whitelist setup started.");

const mediaGallery = new MediaGalleryBuilder()
.addItems([
{
media: {
url: "https://r2.fivemanage.com/c5R8i5l3IaIkvuFXePEUX/7f158542f31fd37a120cd08a7cf1493a_720w.gif"
},
type: "image"
}
]);


const applyButton = new ButtonBuilder()
.setCustomId(open_questions.id)
.setLabel("Apply Whitelist")
.setStyle(ButtonStyle.Secondary);

if (open_questions.emoji) {
applyButton.setEmoji(open_questions.emoji);
} else {
applyButton.setEmoji({ name: 'verify_green', id: '1376781430075686983' });
}

const actionRow = new ActionRowBuilder()
.addComponents(applyButton);

const container_component = new ContainerBuilder()
.addMediaGalleryComponents(mediaGallery)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("# RECKON CITY WHITELIST")
)
.addSeparatorComponents(
new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Large)
)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent(
"## Apply Now For Whitelist\n\n" +
"- Interview : - Whitelist Interviews are available 12x7\n\n" +
"- Availability : - We're usually available peak time : 10.00 AM to 11.00 PM\n\n"
)
)
.addActionRowComponents(actionRow)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("### RECKON CITY Management")
);

try {
await interaction.channel.send({
components: [container_component],
flags: MessageFlags.IsComponentV2,
});

await interaction.editReply({
content: "✅ Whitelist setup completed.",
flags: MessageFlags.Ephemeral,
});
} catch (error) {
console.error("Error in whitelist setup:", error);
await interaction.editReply({
content: "❌ Failed to setup whitelist. Please check the logs.",
flags: MessageFlags.Ephemeral,
});
}
};

module.exports = {
command: false,
execute: whitelistSetup,
};
const {
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
MessageFlags,
TextDisplayBuilder,
ContainerBuilder,
SeparatorBuilder,
SeparatorSpacingSize,
MediaGalleryBuilder,
} = require("discord.js");
const open_questions = require("../../actions/button/whitelist/open_questions");

const whitelistSetup = async (interaction, options) => {
console.log("Whitelist setup started.");

const mediaGallery = new MediaGalleryBuilder()
.addItems([
{
media: {
url: "https://r2.fivemanage.com/c5R8i5l3IaIkvuFXePEUX/7f158542f31fd37a120cd08a7cf1493a_720w.gif"
},
type: "image"
}
]);


const applyButton = new ButtonBuilder()
.setCustomId(open_questions.id)
.setLabel("Apply Whitelist")
.setStyle(ButtonStyle.Secondary);

if (open_questions.emoji) {
applyButton.setEmoji(open_questions.emoji);
} else {
applyButton.setEmoji({ name: 'verify_green', id: '1376781430075686983' });
}

const actionRow = new ActionRowBuilder()
.addComponents(applyButton);

const container_component = new ContainerBuilder()
.addMediaGalleryComponents(mediaGallery)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("# RECKON CITY WHITELIST")
)
.addSeparatorComponents(
new SeparatorBuilder().setSpacing(SeparatorSpacingSize.Large)
)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent(
"## Apply Now For Whitelist\n\n" +
"- Interview : - Whitelist Interviews are available 12x7\n\n" +
"- Availability : - We're usually available peak time : 10.00 AM to 11.00 PM\n\n"
)
)
.addActionRowComponents(actionRow)
.addTextDisplayComponents(
new TextDisplayBuilder().setContent("### RECKON CITY Management")
);

try {
await interaction.channel.send({
components: [container_component],
flags: MessageFlags.IsComponentV2,
});

await interaction.editReply({
content: "✅ Whitelist setup completed.",
flags: MessageFlags.Ephemeral,
});
} catch (error) {
console.error("Error in whitelist setup:", error);
await interaction.editReply({
content: "❌ Failed to setup whitelist. Please check the logs.",
flags: MessageFlags.Ephemeral,
});
}
};

module.exports = {
command: false,
execute: whitelistSetup,
};
Error in whitelist setup: DiscordAPIError[50035]: Invalid Form Body components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,). at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:748:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1149:23) at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:980:14) at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1293:22) at async TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:195:15) at async Object.whitelistSetup [as execute] (/home/container/commands/setup/whitelist.js:63:9) at async Object.execute (/home/container/commands/setup.js:21:17) at async Object.execute (/home/container/handlers/command.js:26:13) { requestBody: { files: [], json: { content: undefined, tts: false, nonce: undefined, enforce_nonce: false, embeds: undefined, components: [Array], username: undefined, avatar_url: undefined, allowed_mentions: undefined, flags: undefined, message_reference: undefined, attachments: undefined, sticker_ids: undefined, thread_name: undefined, applied_tags: undefined, poll: undefined } }, rawError: { message: 'Invalid Form Body', code: 50035, errors: { components: [Object] } }, code: 50035, status: 400, method: 'POST', url: 'https://discord.com/api/v10/channels/1372120935607566426/messages' } @treble/luna
Amgelo
Amgelo6mo ago
MessageFlags.IsComponentsV2
FaFaa
FaFaaOP6mo ago
thank you got it

Did you find this page helpful?