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"
9 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPcheck with <GuildMember>.permissions.had()
Hello, that is not the problem
i successfully checked the user permission. The issue is when he does not have permission, the code does not defer any update to the button leading me to the "Interaction failed" error
you cant do that with promisified collectors
So how should i do that?
you'd have to create a refular one and listen for the ignore event
and dont call it on the channel either
Thank you for the fast response. It worked