Patch webhook type, ActionRowBuilder issue

Hi, I am using the Discord API to patch webhook message using he help of DiscordJS to create components. I'm trying to find and use the correct typescript type/interface for the JSON/Form params of my axios patch message. I am trying with RESTPatchAPIInteractionFollowupJSONBody however when using the component param in the patch message, I get a ts error even though I am assigning the generic type to ActionRowBuilder:
Property 'type' is missing in type 'ActionRowBuilder<ButtonBuilder>' but required in type 'AddUndefinedToPossiblyUndefinedPropertiesOfInterface<APIActionRowComponent<APIMessageActionRowComponent>>'.
Property 'type' is missing in type 'ActionRowBuilder<ButtonBuilder>' but required in type 'AddUndefinedToPossiblyUndefinedPropertiesOfInterface<APIActionRowComponent<APIMessageActionRowComponent>>'.
The code:
const confirm = new ButtonBuilder()
.setCustomId('confirmButton')
.setLabel('It worked')
.setStyle(ButtonStyle.Danger);

const row = new ActionRowBuilder<ButtonBuilder>().addComponents(confirm);

await patchMessage(url, interaction, {
content: 'Button command',
components: [row],
});
const confirm = new ButtonBuilder()
.setCustomId('confirmButton')
.setLabel('It worked')
.setStyle(ButtonStyle.Danger);

const row = new ActionRowBuilder<ButtonBuilder>().addComponents(confirm);

await patchMessage(url, interaction, {
content: 'Button command',
components: [row],
});
The axios function:
export const patchMessage = async (
baseUrl: string,
interaction: APIInteraction,
params: RESTPatchAPIWebhookWithTokenMessageJSONBody,
) => {
const url = `${baseUrl}/webhooks/${interaction.application_id}/${interaction.token}/messages/@original`;

try {
await axios.patch(url, params);
} catch (error) {
throw error;
}
};
export const patchMessage = async (
baseUrl: string,
interaction: APIInteraction,
params: RESTPatchAPIWebhookWithTokenMessageJSONBody,
) => {
const url = `${baseUrl}/webhooks/${interaction.application_id}/${interaction.token}/messages/@original`;

try {
await axios.patch(url, params);
} catch (error) {
throw error;
}
};
Not sure where to go from here...
4 Replies
d.js toolkit
d.js toolkit10mo 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
ThatSameer
ThatSameerOP10mo ago
To clarify, the error is coming from components: [row]
Squid
Squid10mo ago
Can you try calling .toJSON() on row? API objects are generally independent from builders, but that method converts the builders into API data
ThatSameer
ThatSameerOP10mo ago
Ah thats actually fixed it 👏👏👏👏 Legend, thank you v much
Want results from more Discord servers?
Add your server