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
- 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β’8mo ago
Message Not Public
Sign In & Join Server To View
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)
ThxIt works!!!! Canβt believe I overlooked this. Thanks so much