Interaction replying with string works but doesn't work when I return a button

Hey, I started creating a discord bot. It returns a link for the user to click on but it's pretty ugly so i wanted to move over to a button, but when I do this, I am not getting any errors in my console, but running the slash command gives me "An error has occurred." in discord.

Currently this works fine:
await interaction.reply({ content: 'Please log in on our website to sync your account: ' + url});

I copied the official discord.js example with plain strings to keep things simple but even that won't work. If I replace the above line with this I'll get the error:

const confirm = new ButtonBuilder()
            .setCustomId('confirm')
            .setLabel('Confirm')
            .setStyle(ButtonStyle.Danger);

        const cancel = new ButtonBuilder()
            .setCustomId('cancel')
            .setLabel('Cancel')
            .setStyle(ButtonStyle.Secondary);

        const row = new ActionRowBuilder()
            .addComponents(cancel, confirm);

        await interaction.reply({
            content: `Are you sure?`,
            components: [row],
        });
Was this page helpful?