Display a random button array

Hello, I created several buttons in a file, then put them in an array to mix them up for random output. Random works fine, but when I want to display this button array under an embed, it doesn't work. I get an error (view picture). I've been looking for a few days, but I can't figure out how to do it.
const { ButtonBuilder, ButtonStyle } = require('discord.js');

const spellOne = new ButtonBuilder()
.setCustomId('1')
.setLabel('1')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

const spellTwo = new ButtonBuilder()
.setCustomId('2')
.setLabel('2')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

const spellThree = new ButtonBuilder()
.setCustomId('3')
.setLabel('3')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

const spellFour = new ButtonBuilder()
.setCustomId('4')
.setLabel('4')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

const spellFive = new ButtonBuilder()
.setCustomId('5')
.setLabel('5')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

function shuffleArray (array) {
array.sort(() => Math.random() - 0.5);
}

const arraySpells = [spellOne, spellTwo, spellThree, spellFour, spellFive];
shuffleArray(arraySpells);
console.log(typeof arraySpells);

module.exports = arraySpells;
const { ButtonBuilder, ButtonStyle } = require('discord.js');

const spellOne = new ButtonBuilder()
.setCustomId('1')
.setLabel('1')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

const spellTwo = new ButtonBuilder()
.setCustomId('2')
.setLabel('2')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

const spellThree = new ButtonBuilder()
.setCustomId('3')
.setLabel('3')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

const spellFour = new ButtonBuilder()
.setCustomId('4')
.setLabel('4')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

const spellFive = new ButtonBuilder()
.setCustomId('5')
.setLabel('5')
.setStyle(ButtonStyle.Primary)
.setEmoji('979861780291522590');

function shuffleArray (array) {
array.sort(() => Math.random() - 0.5);
}

const arraySpells = [spellOne, spellTwo, spellThree, spellFour, spellFive];
shuffleArray(arraySpells);
console.log(typeof arraySpells);

module.exports = arraySpells;
try {
const confirmation = await response.awaitMessageComponent({filter: collectorFilterUser, time: 20_000});

if (confirmation.customId === 'accept') {

const rowArraySpells = new ActionRowBuilder().addComponents([arraySpells]);
await confirmation.update({embeds: [battleEmbedRoundOne], components: [rowArraySpells]});

}


} catch (error) {
await interaction.editReply({ embeds: [timeoutEmbed], components: [] });
}
try {
const confirmation = await response.awaitMessageComponent({filter: collectorFilterUser, time: 20_000});

if (confirmation.customId === 'accept') {

const rowArraySpells = new ActionRowBuilder().addComponents([arraySpells]);
await confirmation.update({embeds: [battleEmbedRoundOne], components: [rowArraySpells]});

}


} catch (error) {
await interaction.editReply({ embeds: [timeoutEmbed], components: [] });
}
- node.js v20.10.0 - discordjs v8.15.6
No description
4 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! - Marked as resolved by OP
!"Unkown
!"Unkown8mo ago
arraySpells already an array
No description
!"Unkown
!"Unkown8mo ago
so u dont need to make it another array .addComponents(arraySpeels) ✅
Xardass
XardassOP8mo ago
God... I'm dumb. 🤣 Thank guy. :8emojinude15:
Want results from more Discord servers?
Add your server