Receiving specific buttons

if (interaction.type === ComponentType.Button){
console.log('Captcha')
console.log(interaction.customId === 'captchaIns')
if (interaction.customId === 'captchaIns'){
console.log('Captcha')
}
}
if (interaction.type === ComponentType.Button){
console.log('Captcha')
console.log(interaction.customId === 'captchaIns')
if (interaction.customId === 'captchaIns'){
console.log('Captcha')
}
}
Here is my button builder
const instructionsButton = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('captchaIns')
.setLabel('I have read the Instuctions')
.setEmoji(':unlock_1:')
.setStyle(ButtonStyle.Secondary)
)
const instructionsButton = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('captchaIns')
.setLabel('I have read the Instuctions')
.setEmoji(':unlock_1:')
.setStyle(ButtonStyle.Secondary)
)
Console Output
Captcha
false
Captcha
false
How do wait and get the customId of the button
10 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
PAdventures
PAdventuresOP3y ago
Node: v16.14.0
Node: v16.14.0
조아오
조아오3y ago
You can: Create a collector or listen to the interactionCreate event and add the proper filter to execute the function you want
d.js docs
d.js docs3y ago
guide Interactions: Component collectors read more
조아오
조아오3y ago
It has an hyperlink to the collectors guide
PAdventures
PAdventuresOP3y ago
where do i put the collector, in the interactionCreate or the file where the button is? If i add this
const collector = message.createMessageComponentCollector({ componentType: ComponentType.Button});

collector.on('collect', i => {
if (i.customId === 'captchaIns'){
console.log('ABC')
}
});
const collector = message.createMessageComponentCollector({ componentType: ComponentType.Button});

collector.on('collect', i => {
if (i.customId === 'captchaIns'){
console.log('ABC')
}
});
into my interactionCreate file, it will log ABC?
조아오
조아오3y ago
The file where you reply to the interaction
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventuresOP3y ago
already specified -> false
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server