So, i started using discord.js a few weeks ago, and when i started interactions, i got a problem, i have no error in the terminal, but i have “failed to interact”, i don’t know why, i have a few programs, but i use two to get the bot interact rn :
interactionCreate.js :
const { Events, Client } = require('discord.js');
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } = require('discord.js');
module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
const channel = interaction.channel;
if (interaction.isChatInputCommand()) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(`Error executing ${interaction.commandName} command.`);
console.error(error);
}
} else if (interaction.isButton()) {
const message = interaction.message;
// interaction.reply("Vous avez désormais commencé votre aventure ! Il est temps pour vous de découvrir les commandes importantes à l'aide de la commande /help");
} else if (interaction.isStringingSelectMenu()) {
channel.send("Merci d'appuyer sur le bouton pour commencer votre aventure !");
}
}
};
and start.js :
const { SlashCommandBuilder } = require("discord.js");
const { EmbedBuilder } = require("discord.js");
const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName('start')
.setDescription('Commencer votre aventure...'),
async execute(interaction) {
console.log('Deferring reply...');
await interaction.deferReply();
console.log('Reply deferred');
const startEmbed = new EmbedBuilder()
.setColor(0x6a00ff)
.setTitle("Commencer votre aventure")
.setDescription(
"Il est temps pour vous de commencer votre aventure dans le monde du show-business, à essayer de vous faire une place."
)
.addFields(
{
name: "Info n°1",
value: "Attention, des spoilers sont inclus dans ce jeu !",
},
{
name: "Info n°2",
value:
"Il sera strictement impossible de revenir en arrière ! Attention aux choix que vous ferez, ils peuvent avoir de graves répercussions.",
},
{
name: "Info n°3",
value:
"Si vous avez un bug ou une erreur, merci de les signaler en message privé à guiireg.",
},
{
name: "Info n°4",
value:
"Mais la règle la plus importante, n'oubliez pas de vous amuser, c'est le plus important !",
}
)
.setImage(
"https://www.melty.fr/wp-content/uploads/meltyfr/2023/01/001_size10-5.jpg.webp"
);
const start = new ButtonBuilder()
.setCustomId(`${interaction.id}_start`)
.setLabel("Commencer votre partie dès maintenant")
.setStyle(ButtonStyle.Primary);
const startafter = ButtonBuilder.from(start)
.setDisabled(true)
.setCustomId(`${interaction.id}_after`);
const row = new ActionRowBuilder().addComponents(start);
const rowafter = new ActionRowBuilder().addComponents(startafter);
interaction.editReply({
embeds: [startEmbed],
components: [row],
});
const filter = (i) => i.customId === `${interaction.id}_start`; // Vérifie l'identifiant de l'interaction
const collector = interaction.channel.createMessageComponentCollector({
filter,
});
collector.on("collect", async (i) => {
console.log('Collector event handler called');
await interaction.followUp(
"Vous avez désormais commencé votre aventure ! Ilc est temps pour vous de découvrir les commandes importantes à l'aide de la commande /help"
);
await interaction.editReply({
embeds: [startEmbed],
components: [rowafter],
});
});
collector.on("end", (collected) =>
console.log(`Collected ${collected.size} items`)
);
}
};
I need help, thanks !
i tried changing reply in defferReply, i tried other things, like changing text etc… but nothing worked, i want to not get the bot sending the message twice (which why i used the “//”, and fix the failed to interact


