I know that many have asked this question before, but cannot seem to find a solution that will fix my case of the "This interaction failed" error that occurs when clicking a button from a slash command. I am using the Discord.js and Node.js framewords.
The code relating to this embed and the buttons is as follows:
client.on("ready", () => {
...
let commands;
if (guild) {
commands = guild.commands;
} else {
commands = client.application?.commands;
}
...
commands.create({
name: "requirements",
description: "Posts the requirements to join the team.",
});
if (commandName === "requirements") {
const row = new Discord.ActionRowBuilder()
.addComponents(
new Discord.ButtonBuilder()
.setCustomId("staff")
.setLabel("Staff")
.setStyle(ButtonStyle.Primary),
new Discord.ButtonBuilder()
.setCustomId("player")
.setLabel("Player")
.setStyle(ButtonStyle.Success),
new Discord.ButtonBuilder()
.setCustomId("content")
.setLabel("Content")
.setStyle(ButtonStyle.Success),
new Discord.ButtonBuilder()
.setCustomId("fx")
.setLabel("FX")
.setStyle(ButtonStyle.Danger)
);
const mainEmbed = new Discord.EmbedBuilder()
.setColor(0x0088FF)
.setTitle("How to join Aspect Esports")
.setDescription("Please click one of the buttons below for information that corresponds to what you are looking to join as.");
await interaction.reply({
embeds: [mainEmbed],
components: [row]
});
const staffEmbed = new Discord.EmbedBuilder()
.setColor(0x0088FF)
.setTitle("Management / Moderator")
.setDescription("• Must have a very good resume\n• Be very active in server\n• Be friendly and non toxic\nSubmit an application in <┃#apply-for-staff>");
const playerEmbed = new Discord.EmbedBuilder()
.setColor(0x0088FF)
.setTitle("Player")
.setDescription("**Competitive Player:**\n• Must be active every day\n• Have 7k+ PR\n• Be in Champion Division every season\n• Compete in all Fortnite tournaments\n• Represent our team\n• Will be PAID (soon)\n\n**Pro Competitive Player:**\n• Must be active every day\n• Have 25k+ PR\n• Be in Champion Division every season\n• Compete in all Fortnite tournaments\n• Represent our team\n• Will be PAID (soon)\n\n**Academy Player:**\n• Must be active every day\n• Have 3k+ PR\n• Be in Champion Division every season\n• Compete in all Fortnite tournaments\n• Represent our team\n• Will be PAID (soon)\n\n**Creative Player:**\n• Have fast and smooth mechanics\n• Have unique mechanics\n• Be entertaining to watch\n• Be fast/flashy or fast/smooth\n• Must be able to provide clips for team videos");
const contentEmbed = new Discord.EmbedBuilder()
.setColor(0x0088FF)
.setTitle("Content Creator")
.setDescription("• Have at least 250+ followers on any platform\n• Post content/stream at least once a week\n• Upload in at least 1080p 60fps quality\n• Be entertaining\n• Be funny\n• Might be PAID (not sure yet)");
const fxEmbed = new Discord.EmbedBuilder()
.setColor(0x0088FF)
.setTitle("FX")
.setDescription("**VFX:**\n• Be able to edit videos for the team for FREE\n• Have unique effects\n• Make the videos entertaining\n• Edit videos in at least 1080p 60fps quality\n• DO NOT STEAL WORK\n• Will be PAID (Soon)\n\n\n• GFX:\n• Be able to edit graphics for the team for FREE\n• Be able to make banners, logos, thumbnails, and more\n• Have high quality work that is appealing\n• Will be PAID (soon)");
const collector = interaction.channel.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 15000
});
collector.on('collect', async i => {
if (i.customID === "staff") {
i.deferReply({
embeds: [staffEmbed]
});
} else if (i.customID === "player") {
i.deferReply({
embeds: [playerEmbed]
});
} else if (i.customID === "content") {
i.deferReply({
embeds: [contentEmbed]
});
} else if (i.customID === "fx") {
i.deferReply({
embeds: [fxEmbed]
});
}
});
}
});
