How to create a button with permission

Very similar to the behavior of this button "Mark post as solved" i want to create one the does basically the same.

  1. If the person has permission to click it, executes the function
  2. Else show a ephemeral error message to the user like "Only the original poster or support staff can mark a post as resolved!"
I have this code with works to execute when the user has permission. When he does not have permission i receive the error "Interaction failed"

let botMsg = await channel.send({ embeds: [embed], components: [buttons] })

const filterComponent = (i) => Utils.isStaff(i.member);
let result = await channel.awaitMessageComponent({ filter: filterComponent, time: 300000, max: 1 });
image.png
Was this page helpful?