I am a beginner coder in javascript and especially discord.js After wrapping my head around the discord.js guide, I still cannot get the collector to work.
client.on('interactionCreate', interaction => {
if (!interaction.isButton()) return;
const filter = i => i.customId === '1' || i.customId === "2";
const collectchannel = interaction.channel;
const collector = collectchannel.createMessageComponentCollector( filter, { time: 10000 });
collector.on('collect', i => {
if (i.customId === '1') {
client.commands.get('help').execute(interaction, 1, Discord);
} else if (i.customId === '2') {
client.commands.get('help').execute(interaction, 2, Discord);
}
});
collector.on('end', collected => {
console.log(`Collected ${collected.size} interactions.`);
});
});
When I press my button, the collect function doesn't do anything. I tried placing a console.log("test") but it doesn't fire. However, the collector.on('end', collected => { does in fact fire.
This may be because I'm not a good coder. If you can, please help!