The button collector is not working, I'm doing something wrong

Code:
if (usdPricePerByteFormatted === 0) {
const confirmEmbedZero = new EmbedBuilder()
. . .

const yesZero = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('Yes')
.setCustomId('yeschannel')
.setStyle(ButtonStyle.Success)
)
const noZero = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('No')
.setCustomId('nochannel')
.setStyle(ButtonStyle.Danger)
)
return interaction.editReply({
embeds: [confirmEmbedZero],
ephemeral: true,
components: [yesZero, noZero]
})
}

const filter = i => i.customId === 'yeschannel' && i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter })

collector.on("collect", async i => {
console.log('yea!!')
})
collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
if (usdPricePerByteFormatted === 0) {
const confirmEmbedZero = new EmbedBuilder()
. . .

const yesZero = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('Yes')
.setCustomId('yeschannel')
.setStyle(ButtonStyle.Success)
)
const noZero = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('No')
.setCustomId('nochannel')
.setStyle(ButtonStyle.Danger)
)
return interaction.editReply({
embeds: [confirmEmbedZero],
ephemeral: true,
components: [yesZero, noZero]
})
}

const filter = i => i.customId === 'yeschannel' && i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter })

collector.on("collect", async i => {
console.log('yea!!')
})
collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
I do it in command file, not in interactionCreate
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Alexcitten
AlexcittenOP2y ago
Thank you
Want results from more Discord servers?
Add your server