Eccléria
Eccléria
DIAdiscord.js - Imagine an app
Created by Eccléria on 5/31/2025 in #djs-questions
Components v2 - SectionBuilder with button
Hey everyone. I'm trying to add a ButtonBuilder to a SectionBuilder, nested in a ContainerBuilder. But when trying to post the message, I get an error:
path/node_modules/@discordjs/builders/dist/index.mjs:486
throw new RangeError("Non-premium buttons must have a label and/or an emoji.");
^

RangeError: Non-premium buttons must have a label and/or an emoji.
at validateRequiredButtonParameters (path/node_modules/@discordjs/builders/dist/index.mjs:486:13)
at ButtonBuilder.toJSON (path/node_modules/@discordjs/builders/dist/index.mjs:654:5)
at SectionBuilder.toJSON (path/node_modules/@discordjs/builders/dist/index.mjs:2102:59)
at path/src/commands/polls/polls.js:271:34
at Array.forEach (<anonymous>)
at Object.action (path/src/commands/polls/polls.js:252:20)

Node.js v20.11.1
path/node_modules/@discordjs/builders/dist/index.mjs:486
throw new RangeError("Non-premium buttons must have a label and/or an emoji.");
^

RangeError: Non-premium buttons must have a label and/or an emoji.
at validateRequiredButtonParameters (path/node_modules/@discordjs/builders/dist/index.mjs:486:13)
at ButtonBuilder.toJSON (path/node_modules/@discordjs/builders/dist/index.mjs:654:5)
at SectionBuilder.toJSON (path/node_modules/@discordjs/builders/dist/index.mjs:2102:59)
at path/src/commands/polls/polls.js:271:34
at Array.forEach (<anonymous>)
at Object.action (path/src/commands/polls/polls.js:252:20)

Node.js v20.11.1
I tried to look at an error in my code but I cannot find one.
const container = new ContainerBuilder();

//create button
const buttonId = "polls_" + idx.toString();
const button = createButton(buttonId, field, ButtonStyle.Secondary, emote);
const fieldSection = new SectionBuilder().setButtonAccessory(button);

//line 271
console.log(fieldSection.toJSON());

container.addSectionComponents(fieldSection);
interaction.channel.send({flags: MessageFlags.IsComponentsV2, components: [container]});

//creatButton function:
export const createButton = (id, label, style, emoji) => {
const button = new ButtonBuilder().setCustomId(id).setStyle(style);
if (label) button.setLabel(label);
if (emoji) button.setEmoji(emoji);
return button;
};
const container = new ContainerBuilder();

//create button
const buttonId = "polls_" + idx.toString();
const button = createButton(buttonId, field, ButtonStyle.Secondary, emote);
const fieldSection = new SectionBuilder().setButtonAccessory(button);

//line 271
console.log(fieldSection.toJSON());

container.addSectionComponents(fieldSection);
interaction.channel.send({flags: MessageFlags.IsComponentsV2, components: [container]});

//creatButton function:
export const createButton = (id, label, style, emoji) => {
const button = new ButtonBuilder().setCustomId(id).setStyle(style);
if (label) button.setLabel(label);
if (emoji) button.setEmoji(emoji);
return button;
};
When investigating the Builders, I have this weird accessory in the SectionBuilder:
SectionBuilder {
data: { type: 9 },
//components
accessory: ButtonBuilder {
data: {
type: 2,
data: {
type: 2,
emoji: undefined,
custom_id: 'polls_0',
style: 2,
label: 'Choice 1'
}
}
}
}
SectionBuilder {
data: { type: 9 },
//components
accessory: ButtonBuilder {
data: {
type: 2,
data: {
type: 2,
emoji: undefined,
custom_id: 'polls_0',
style: 2,
label: 'Choice 1'
}
}
}
}
32 replies
DIAdiscord.js - Imagine an app
Created by Eccléria on 8/23/2022 in #djs-questions
TextChannel.bulkDelete description
5 replies
DIAdiscord.js - Imagine an app
Created by Eccléria on 7/30/2022 in #djs-questions
Weird PermissionOverwrite triggers ChannelUpdate for every guildChannel
9 replies
DIAdiscord.js - Imagine an app
Created by Eccléria on 7/20/2022 in #djs-questions
Guild Ban triggers wrong event
When I tested out my bot on a test server a few minutes ago, I realised that when banning a user, it's the guildMemberRemove event that fire, and not the guildBanAdd event. I've a console.log on both events and only one was triggered.
24 replies
DIAdiscord.js - Imagine an app
Created by Eccléria on 7/19/2022 in #djs-questions
How to send again a gif recovered from a previous message ?
26 replies