Type error in Button Builder

module.exports = {
setup: (client: Client) => {
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isModalSubmit() || interaction.customId !== "storyModal")
return;

await interaction.deferReply();

const serverID = interaction.guild?.id || "DM";
const userID = interaction.user.id;
const storyID = serverID + userID;

const alreadyExist = await getWelcomeInfoByStoryID(storyID);
if (alreadyExist[0]) {
await interaction.editReply({
content: "You already have a running story!",
});

return;
}

const storyTitle = interaction.fields.getTextInputValue("storyTitle");
const story = interaction.fields.getTextInputValue("story");

await createStory(storyID, storyTitle, userID, Date.now());


const Colab = new ButtonBuilder()
.setCustomId("colab")
.setLabel("Add Story")
.setStyle(ButtonStyle.Primary);

const remove = new ButtonBuilder()
.setCustomId("remove")
.setLabel("Remove Story")
.setStyle(ButtonStyle.Danger);

const end = new ButtonBuilder()
.setCustomId("end")
.setLabel("End Story")
.setStyle(ButtonStyle.Success);

const row = new ActionRowBuilder().addComponents(Colab, end, remove);

await interaction.editReply({
content: "Your submission was received successfully!",
components: [row],
}); ^^^
});
},
};
module.exports = {
setup: (client: Client) => {
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isModalSubmit() || interaction.customId !== "storyModal")
return;

await interaction.deferReply();

const serverID = interaction.guild?.id || "DM";
const userID = interaction.user.id;
const storyID = serverID + userID;

const alreadyExist = await getWelcomeInfoByStoryID(storyID);
if (alreadyExist[0]) {
await interaction.editReply({
content: "You already have a running story!",
});

return;
}

const storyTitle = interaction.fields.getTextInputValue("storyTitle");
const story = interaction.fields.getTextInputValue("story");

await createStory(storyID, storyTitle, userID, Date.now());


const Colab = new ButtonBuilder()
.setCustomId("colab")
.setLabel("Add Story")
.setStyle(ButtonStyle.Primary);

const remove = new ButtonBuilder()
.setCustomId("remove")
.setLabel("Remove Story")
.setStyle(ButtonStyle.Danger);

const end = new ButtonBuilder()
.setCustomId("end")
.setLabel("End Story")
.setStyle(ButtonStyle.Success);

const row = new ActionRowBuilder().addComponents(Colab, end, remove);

await interaction.editReply({
content: "Your submission was received successfully!",
components: [row],
}); ^^^
});
},
};
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.ts(2322)
index.d.ts(283, 3): 'type' is declared here.
Type 'ActionRowBuilder<AnyComponentBuilder>' is not assignable to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
Property 'type' is missing in type 'ActionRowBuilder<AnyComponentBuilder>' but required in type 'ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>'.ts(2322)
index.d.ts(283, 3): 'type' is declared here.
10 Replies
d.js toolkit
d.js toolkit8mo 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!
d.js docs
d.js docs8mo ago
In TypeScript the ActionRowBuilder class has a generic type parameter that specifies the type of component the action row holds:
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
ItsPinion
ItsPinionOP8mo ago
can i not add modal in model submit interaction?
ItsPinion
ItsPinionOP8mo ago
@New Year's Predicate
Property 'showModal' does not exist on type 'ModalSubmitInteraction<CacheType>'.ts(2339)
Property 'showModal' does not exist on type 'ModalSubmitInteraction<CacheType>'.ts(2339)
Kinect3000
Kinect30008mo ago
You can’t reply to a modal w/ a modal You should be using the button interaction that was collected anyways, not the modal interaction
ItsPinion
ItsPinionOP8mo ago
how do i get button interaction?
Kinect3000
Kinect30008mo ago
Add the param in the collect event Kinda surprised the stuff in the collect event runs tbh
ItsPinion
ItsPinionOP8mo ago
ah I see... thnx man....
d.js docs
d.js docs8mo ago
You can control which entities receive notifications via the allowedMentions option. You can: - Set a default on the client - Set for a specific message - Use the repliedUser key to disable in-line reply mentions
{ ..., allowedMentions: { parse: ["users", "roles"] } }
{ ..., allowedMentions: { parse: ["users", "roles"] } }
Want results from more Discord servers?
Add your server