The button collector is not working, I'm doing something wrong
Code:
I do it in command file, not in interactionCreate
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`);
});
2 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Thank you