Make a button executable only by the command executer

Hello, I want to make a button only executable only by the person who ran it. For example, if person A runs command fuzz only they are allowed to click on button B I thought this would work it seems to split out [ERROR] Encountered error while handling an interaction handler run method for interaction-handler "bankButton" at path "C:\Users\Isidr\Documents\GitHub\cobaltia\cobaltia\dist\interaction-handlers\buttons\bankButton.js" TypeError: Cannot read properties of undefined (reading 'id')
const user = interaction.message.mentions.users.first()!;
if (interaction.user.id !== user.id) return;
const user = interaction.message.mentions.users.first()!;
if (interaction.user.id !== user.id) return;
Also, update the tags to include 14.14.x
Solution:
I would add userId to the button custom id and regex match it. One way it says you can do it in guide iirc
Jump to solution
10 Replies
Juan Pablo
Juan PabloOP11mo ago
hello? anyone please imbaby just added so many people
vladdy
vladdy11mo ago
OH GOD LOL
Juan Pablo
Juan PabloOP11mo ago
oops
vladdy
vladdy11mo ago
anyways mentions arent what you wanna use iirc
Juan Pablo
Juan PabloOP11mo ago
I couldn't find anything in the server guide it would be nice to know what to do after a long time of not getting help
Solution
Jay
Jay11mo ago
I would add userId to the button custom id and regex match it. One way it says you can do it in guide iirc
vladdy
vladdy11mo ago
also don't you want to just check if message.author.id === interaction.user.id?
Juan Pablo
Juan PabloOP11mo ago
author is the bot
vladdy
vladdy11mo ago
i just integrate it into the custom id
Juan Pablo
Juan PabloOP11mo ago
yeah I don't know why I didn't think of this
Want results from more Discord servers?
Add your server