Can someone fix this? Buttons are not working for this embed

client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'expedition') {
const embed = new EmbedBuilder()
.setColor('Random')
.setThumbnail('https://media.discordapp.net/attachments/965922634875416606/1146195590355619992/oi8uyoih.png?width=443&height=443')
.addFields({
name: 'Host',
value: 'host name',
inline: true,
}, {
name: 'Location',
value: 'location selected',
inline: true,
})

const join = new ButtonBuilder()
.setCustomId('join')
.setLabel('Join')
.setStyle(ButtonStyle.Success);

const start = new ButtonBuilder()
.setCustomId('start')
.setLabel('Start')
.setStyle(ButtonStyle.Secondary);

const end = new ButtonBuilder()
.setCustomId('end')
.setLabel('End')
.setStyle(ButtonStyle.Primary);

const row = new ActionRowBuilder()
.addComponents(join, start, end);

await interaction({
components: [row],
});

interaction.reply({ embeds: [embed] });
}
});
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'expedition') {
const embed = new EmbedBuilder()
.setColor('Random')
.setThumbnail('https://media.discordapp.net/attachments/965922634875416606/1146195590355619992/oi8uyoih.png?width=443&height=443')
.addFields({
name: 'Host',
value: 'host name',
inline: true,
}, {
name: 'Location',
value: 'location selected',
inline: true,
})

const join = new ButtonBuilder()
.setCustomId('join')
.setLabel('Join')
.setStyle(ButtonStyle.Success);

const start = new ButtonBuilder()
.setCustomId('start')
.setLabel('Start')
.setStyle(ButtonStyle.Secondary);

const end = new ButtonBuilder()
.setCustomId('end')
.setLabel('End')
.setStyle(ButtonStyle.Primary);

const row = new ActionRowBuilder()
.addComponents(join, start, end);

await interaction({
components: [row],
});

interaction.reply({ embeds: [embed] });
}
});
13 Replies
d.js toolkit
d.js toolkit15mo 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!
Danial
Danial15mo ago
await interaction({
components: [row],
});
await interaction({
components: [row],
});
What are you trying to do here?
treble/luna
treble/luna15mo ago
i told you what to do
M1hnea
M1hneaOP15mo ago
I just want the buttons on that embed
treble/luna
treble/luna15mo ago
then pass them in along with your embeds embeds: [], components: []
M1hnea
M1hneaOP15mo ago
I need to put something in []?
Danial
Danial15mo ago
The embeds and components you want the message to have
d.js docs
d.js docs15mo ago
guide Message Components: Buttons read more
M1hnea
M1hneaOP15mo ago
Oh ok
if (interaction.commandName === 'expedition') {
const embed = new EmbedBuilder()
.setColor('Random')
.setThumbnail('https://media.discordapp.net/attachments/965922634875416606/1146195590355619992/oi8uyoih.png?width=443&height=443')
.addFields({
name: 'Host',
value: 'host name',
inline: true,
}, {
name: 'Location',
value: 'location selected',
inline: true,
})

const join = new ButtonBuilder()
.setCustomId('join')
.setLabel('Join')
.setStyle(ButtonStyle.Success);

const start = new ButtonBuilder()
.setCustomId('start')
.setLabel('Start')
.setStyle(ButtonStyle.Secondary);

const end = new ButtonBuilder()
.setCustomId('end')
.setLabel('End')
.setStyle(ButtonStyle.Primary);

const row = new ActionRowBuilder()
.addComponents(join, start, end);

await interaction({
components: [row],
embeds: [embed],
});

interaction.reply({ embeds: [embed] });
}
});
if (interaction.commandName === 'expedition') {
const embed = new EmbedBuilder()
.setColor('Random')
.setThumbnail('https://media.discordapp.net/attachments/965922634875416606/1146195590355619992/oi8uyoih.png?width=443&height=443')
.addFields({
name: 'Host',
value: 'host name',
inline: true,
}, {
name: 'Location',
value: 'location selected',
inline: true,
})

const join = new ButtonBuilder()
.setCustomId('join')
.setLabel('Join')
.setStyle(ButtonStyle.Success);

const start = new ButtonBuilder()
.setCustomId('start')
.setLabel('Start')
.setStyle(ButtonStyle.Secondary);

const end = new ButtonBuilder()
.setCustomId('end')
.setLabel('End')
.setStyle(ButtonStyle.Primary);

const row = new ActionRowBuilder()
.addComponents(join, start, end);

await interaction({
components: [row],
embeds: [embed],
});

interaction.reply({ embeds: [embed] });
}
});
is it good now? sorry but I really don't know on buttons
Danial
Danial15mo ago
Not sure what you're trying to do with interaction(), you'd add that components property to reply() and remove interaction()
treble/luna
treble/luna15mo ago
please read the guide you were sent dont just assume things
M1hnea
M1hneaOP15mo ago
when I run the commad, I want that bot to reply to me with the embed and buttons
Danial
Danial15mo ago
You've already been told what to do, please read what we said
Want results from more Discord servers?
Add your server