Validation error

What can cause this error on button click? It's this specific button (dailyneko-modal), nothing else causes this. dailyneko-cancel works. Components creator:
const components = [
new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId("dailyneko-modal")
.setLabel("Open Modal")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("dailyneko-done")
.setLabel("Done")
.setStyle(allDone ? ButtonStyle.Success : ButtonStyle.Secondary)
.setDisabled(!allDone),
new ButtonBuilder()
.setCustomId("dailyneko-cancel")
.setLabel("Cancel")
.setStyle(ButtonStyle.Danger)
)
]
const components = [
new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId("dailyneko-modal")
.setLabel("Open Modal")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("dailyneko-done")
.setLabel("Done")
.setStyle(allDone ? ButtonStyle.Success : ButtonStyle.Secondary)
.setDisabled(!allDone),
new ButtonBuilder()
.setCustomId("dailyneko-cancel")
.setLabel("Cancel")
.setStyle(ButtonStyle.Danger)
)
]
Button handler:
@ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.Button
})
export class DailyNekoButtonsHandler extends InteractionHandler {
public parse(interaction: ButtonInteraction): Option<void> {
return interaction.customId.startsWith("dailyneko") ? this.some() : this.none();
}

public async run(interaction: ButtonInteraction) {
const task = interaction.customId.split("-").at(1)!;

const data = interaction.message.embeds[0].data;
let artist_name = data.fields![0].value!;
artist_name = artist_name === "N/A" ? "" : artist_name;

let artist_url = data.fields![1].value!;
artist_url = artist_url === "N/A" ? "" : artist_url;

let source_url = data.fields![2].value!;
source_url = source_url === "N/A" ? "" : source_url;

let neko_url = data.fields![3].value!;
neko_url = neko_url === "N/A" ? "" : neko_url;

switch (task) {
case "modal":
interaction.showModal(dailyNekoModal(artist_name, artist_url, source_url, neko_url));
break
case "done":
await interaction.deferReply();
const channel = interaction.guild?.channels.cache.get(this.container.config.config.channels.daily_neko) as TextBasedChannel;
await sendDailyneko(webhook, channel, artist_name, artist_url, source_url, neko_url);
interaction.message.edit({
components: [],
content: "Sent daily neko."
});
break;
case "cancel":
interaction.update({
components: [],
content: "Cancelled."
})
break;
}
}
}
@ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.Button
})
export class DailyNekoButtonsHandler extends InteractionHandler {
public parse(interaction: ButtonInteraction): Option<void> {
return interaction.customId.startsWith("dailyneko") ? this.some() : this.none();
}

public async run(interaction: ButtonInteraction) {
const task = interaction.customId.split("-").at(1)!;

const data = interaction.message.embeds[0].data;
let artist_name = data.fields![0].value!;
artist_name = artist_name === "N/A" ? "" : artist_name;

let artist_url = data.fields![1].value!;
artist_url = artist_url === "N/A" ? "" : artist_url;

let source_url = data.fields![2].value!;
source_url = source_url === "N/A" ? "" : source_url;

let neko_url = data.fields![3].value!;
neko_url = neko_url === "N/A" ? "" : neko_url;

switch (task) {
case "modal":
interaction.showModal(dailyNekoModal(artist_name, artist_url, source_url, neko_url));
break
case "done":
await interaction.deferReply();
const channel = interaction.guild?.channels.cache.get(this.container.config.config.channels.daily_neko) as TextBasedChannel;
await sendDailyneko(webhook, channel, artist_name, artist_url, source_url, neko_url);
interaction.message.edit({
components: [],
content: "Sent daily neko."
});
break;
case "cancel":
interaction.update({
components: [],
content: "Cancelled."
})
break;
}
}
}
2 Replies
oriel beck
oriel beckOP7mo ago
This is the modal function:
export function dailyNekoModal(artist_name: string, artist_url: string, source_url: string, neko_url: string) {
return new ModalBuilder()
.setCustomId("dailyneko-modal")
.setTitle("Daily Neko")
.addComponents(
new ActionRowBuilder<TextInputBuilder>()
.addComponents(
new TextInputBuilder()
.setCustomId("artist_name")
.setValue(artist_name || "")
.setLabel("Artist Name")
),
new ActionRowBuilder<TextInputBuilder>()
.addComponents(
new TextInputBuilder()
.setCustomId("artist_url")
.setValue(artist_url || "")
.setLabel("Artist URL")
),
new ActionRowBuilder<TextInputBuilder>()
.addComponents(
new TextInputBuilder()
.setCustomId("source_url")
.setValue(source_url || "")
.setLabel("Source URL")
),
new ActionRowBuilder<TextInputBuilder>()
.addComponents(
new TextInputBuilder()
.setCustomId("neko_url")
.setValue(neko_url || "")
.setLabel("Neko URL")
)
)
}
export function dailyNekoModal(artist_name: string, artist_url: string, source_url: string, neko_url: string) {
return new ModalBuilder()
.setCustomId("dailyneko-modal")
.setTitle("Daily Neko")
.addComponents(
new ActionRowBuilder<TextInputBuilder>()
.addComponents(
new TextInputBuilder()
.setCustomId("artist_name")
.setValue(artist_name || "")
.setLabel("Artist Name")
),
new ActionRowBuilder<TextInputBuilder>()
.addComponents(
new TextInputBuilder()
.setCustomId("artist_url")
.setValue(artist_url || "")
.setLabel("Artist URL")
),
new ActionRowBuilder<TextInputBuilder>()
.addComponents(
new TextInputBuilder()
.setCustomId("source_url")
.setValue(source_url || "")
.setLabel("Source URL")
),
new ActionRowBuilder<TextInputBuilder>()
.addComponents(
new TextInputBuilder()
.setCustomId("neko_url")
.setValue(neko_url || "")
.setLabel("Neko URL")
)
)
}
Did a quick check, all parameters are strings (empty strings, but still typeof string) Yeah ok, forgot setStyle so it exploded Please, add better errors for this thing...
Favna
Favna7mo ago
That's on @discordjs/builders, not on sapphire code. That said, currently @sapphire/shapeshift doesn't support custom error messages but I'm literally just now merging the PR so once it's merged it's a matter of DiscordJS contributors updating builders code (could be you!)
Want results from more Discord servers?
Add your server