Hey i was trying to make a url button to my embed when it sent on slashCommand, but when I tried to put the button and use the command I got an error of : DiscordAPIError: Invalid Form Body
I don't know why is that error showing up and my embed is not working/sending.
Node: v17.7.2
Discord.js: 13.2.0
Here is my command:
const { Client, CommandInteraction } = require("discord.js");
const { MessageEmbed } = require('discord.js');
const ee = require('../../config.json');
const { MessageActionRow, MessageButton } = require('discord.js');
module.exports = {
name: "help",
description: "Show all the commands",
/**
*
* @param {Client} client
* @param {CommandInteraction} interaction
* @param {String[]} args
*/
run: async (client, interaction, args) => {
let music = [
"\`play:\` Play a song from YouTube, SoundCloud, & Spotify",
"\`pause:\` Pause the current playing music.",
"\`resume:\` Resume the pause music.",
"\`stop:\` Stop the music.",
'\`loop:\` Loop the current music or the queqe.',
'\`autoplay:\` Autoplay music for you.',
'\`queue:\` Show the music queue.',
'\`volume:\` Adjust the volume of the music.',
'\`seek:\` Rewind the current song to the specified position.',
'\`shuffle:\` Shuffle the music playlist or the queue.',
'\`nowplaying:\` Show the Current music playing.',
'\`save:\` Save the current playing music.',
'\`lyrics:`\ Display the lyrics of the current playing music.',
'`\filter:` Put a filter to a song.'
]
let info = [
'\`ping:\` Pings H_M.',
'\`help:\` Shows all the H_M command lists.',
'\`links:\` Information about H_M.',
'`\avatar:\` Shows the avatar of a user.'
]
const helpembed = new MessageEmbed()
.setThumbnail(client.user.displayAvatarURL())
.setColor(ee.color)
.setTitle(`📫 | Command list of ${client.user.username}`)
.setDescription(`**🎵 - Music**\n• ${music.join("\n • ")}\n**⚙️ - Information**\n• ${info.join("\n • ")}`)
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setLabel('Click here.')
.setStyle('url')
.setURL('https://example.com'),
);
interaction.followUp({ embeds: [helpembed], components: [row] });
},
};
I tried to follow what it said on this documents: https://discordjs.guide/interactions/buttons.html#building-and-sending-buttons but it seems like I did something wrong...
According to the official discord.js guide on buttons => Buttons | Discord.js, there are 5 styles which you can apply to buttons: PRIMARY SECONDARY SUCCESS DANGER LINK. I assume you want to create a button which leads to somewhere as a link so instead of the style in your button being url, change it to LINK so that it is something like this => .setURL('LINK')