Can I disable a button (that has not been assigned to a variable) by using it's custom_id? I am creating buttons dynamically with a for loop with the following code:
if(similarMatchesList){
for (let a = 0; a < similarMatchesList.length; a++){
const current = similarMatchesList[a];
buttons.push(
new ButtonBuilder()
.setCustomId(`${buttonPrefix}${current.id}`)
.setLabel(`${current.name} [${current.id}]`)
.setStyle(ButtonStyle.Secondary)
);
}
}
I am able to pass the buttons into an ActionRowBuilder. Then send the ActionRowBuilder with the message correctly, and I am able to "collect" when the button is interacted with.
But I am struggling with disabling the button (adding setDisabled(true) to it) that was just clicked since I don't have a variable associated with the button. I was hoping to disable the button using it's custom_id, but haven't been able to find a way to do that.
I thought about assigning each button to a new variable as I go through the for loop, but haven't been able to think of a way of doing that.
Thanks for the help in advance!
Discord.js version: 14.14.1
Node version: 20.8.0