Reputation: 47
How to attach more than 5 buttons to a message with discord-buttons, discord.js?
The way I try:
let Buttons = [];
Buttons[0] = new discordButton.MessageButton().setStyle('gray').setID("0").setLabel(' ');
Buttons[1] = new discordButton.MessageButton().setStyle('gray').setID("1").setLabel(' ');
Buttons[2] = new discordButton.MessageButton().setStyle('gray').setID("2").setLabel(' ');
Buttons[3] = new discordButton.MessageButton().setStyle('gray').setID("3").setLabel(' ');
Buttons[4] = new discordButton.MessageButton().setStyle('gray').setID("4").setLabel(' ');
Buttons[5] = new discordButton.MessageButton().setStyle('gray').setID("5").setLabel(' ');
Buttons[6] = new discordButton.MessageButton().setStyle('gray').setID("6").setLabel(' ');
Buttons[7] = new discordButton.MessageButton().setStyle('gray').setID("7").setLabel(' ');
Buttons[8] = new discordButton.MessageButton().setStyle('gray').setID("8").setLabel(' ');
msg.channel.send(`...`, { buttons:Buttons });
The error it gets:
DiscordAPIError: Invalid Form Body
components[0].components[5]: The specified component exceeds the maximum width
components[0].components[6]: The specified component exceeds the maximum width
components[0].components[7]: The specified component exceeds the maximum width
components[0].components[8]: The specified component exceeds the maximum width
method: 'post',
path: '/channels/656858400440975371/messages',
code: 50035,
httpStatus: 400
}
Does it have something to do with my bot account?
Upvotes: 1
Views: 15867
Reputation: 76
You can try doing this:
const msg = await message.channel.send({
embed: YOUR EMBED HERE,
components: [
{
type: 1,
components: [Button[0], Button[1], Button[2], Button[3], Button[4]],
},
{
type: 1,
components: [more, buttons, here, max, 5]
}
{
type: 1,
components: [you, can, do, 5, times]
}
]
});
I hope this helped :D
Upvotes: 6
Reputation: 1079
I suggest that you read through or reference the Discord API documentation, here you could find out the following information:
Reference: https://discord.com/developers/docs/interactions/message-components
Upvotes: 1