Building Embed & 3 Buttons in v14 (use ActionRowBuilder and EmbedBuilder?)

I have a function that 'compiles' and sends an embed and components (which are three buttons) to a text channel: async function sendEmbed(description) { try { const [embedBuilt, buttonRowBuilt] = await Promise.all([ buildEmbed(description), buildButtonRow() ]); const textChannel = client.channels.cache.get(textChannelId); await textChannel.send({ embeds: [embedBuilt.toJSON()], components: [buttonRowBuilt.toJSON()] }) .then((message) => { lastButtonMessageId = message.id; }).catch((error) => { console.error(error); }); } catch (error) { console.error(error); } } The embed seems to be OK. But I know there's definitely something wrong with my ActionRowBuilder 😦 async function buildButtonRow() { const actionRow = new ActionRowBuilder(); actionRow.addComponents(ButtonComponent[[ new ButtonBuilder() .setLabel('Join Queue') .setStyle(ButtonStyle.Success) .setCustomId('join-queue-button'), new ButtonBuilder() .setLabel('Leave Queue') .setStyle(ButtonStyle.Danger) .setCustomId('leave-queue-button'), new ButtonBuilder() .setLabel('Pass Time') .setStyle(ButtonStyle.Primary) .setCustomId('pass-time-button') ]] ); return actionRow } Anyone see obvious issues that I need to fix? Many thanks πŸ™‚
5 Replies
d.js toolkit
d.js toolkitβ€’7mo 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!
Unknown User
Unknown Userβ€’7mo ago
Message Not Public
Sign In & Join Server To View
geeks
geeksOPβ€’7mo ago
am I not doing that correctly with this? actionRow.addComponents(ButtonComponent[[ new ButtonBuilder() .setLabel('Join Queue') .setStyle(ButtonStyle.Success) .setCustomId('join-queue-button'), new ButtonBuilder() .setLabel('Leave Queue') .setStyle(ButtonStyle.Danger) .setCustomId('leave-queue-button'), new ButtonBuilder() .setLabel('Pass Time') .setStyle(ButtonStyle.Primary) .setCustomId('pass-time-button') ]] Yes not sure why that was hanging out there, have removed the ButtonCOmponent πŸ™‚ So unless I've missed something, is it only possible to push these embeds (with buttons) to a textchat channel? I keep seeing/hearing that there is indeed the capability to push/send to the VC's text/side chat - Is this at all possible? (Eg. bots like Statbot seem to be capable of doing so) Thx
d.js docs
d.js docsβ€’7mo ago
:method: VoiceChannel#send @14.15.2 Sends a message to this channel.
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
geeks
geeksOPβ€’7mo ago
It works!!!! Can’t believe I overlooked this. Thanks so much
Want results from more Discord servers?
Add your server