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
Juan Pablo
Juan Pablo108d ago
hello? anyone please imbaby just added so many people
vladdy
vladdy108d ago
OH GOD LOL
Juan Pablo
Juan Pablo108d ago
oops
vladdy
vladdy108d ago
anyways mentions arent what you wanna use iirc
Juan Pablo
Juan Pablo108d 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
Jay108d 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
vladdy108d ago
also don't you want to just check if message.author.id === interaction.user.id?
Juan Pablo
Juan Pablo108d ago
author is the bot
vladdy
vladdy108d ago
i just integrate it into the custom id
Juan Pablo
Juan Pablo108d ago
yeah I don't know why I didn't think of this
Want results from more Discord servers?
Add your server
More Posts
Encountering Error `TypeError: emitter.getMaxListeners is not a function`Happens as soon as I run the code. I am using ts-node so I have no idea if this is the reason why.Problem loading virtual piecesIf I go by file system mode, all commands & listeners get loaded. But if I go by virtual piece routeAm I doing this wrong? Message doesn't send for preconditions, but the precondition works FINEIt just says the usual "The application did not respond."Problem with loader file generator`generate-loader` is generating a loader at unintended location with `.js` extension applied 🤔 AlsChatInputCommandHow to know if a interaction comes from a slash command?[EMPTY_MODULE] Error:I’ve looked at some of the other posts that was also related to this issue and used those solutions Error Handling`[ERROR] Encountered error on message command "test" at path "C:\Users\cmart\Desktop\Discord Bots\SaPaginatedMessage: refresh pages after setPages()How can I update or refresh PaginatedMessage after use setPages()? Currently, I have to click next/pchange PaginatedMessage's selectMenu context nameIs there anyway to change select menu context?NPM script stops working when tsconfig extends @sapphire/ts-configMy npm package has a simple build script: ```json "prebuild": "rimraf dist types", "build": "tsc", `welcome botHow do you make the bot send a welcome messageHow do you register paths for pieces? Also have an additional question when this one is solved.I have a file structure as outlined below, I am wondering how I can make sapphire recognize this patQuestionHow do i get rid of this “warning”(?)frustrating unknown interactionI'm getting alot of unknown interaction errors and I have no idea what it meansDistube and sapphireI am trying to use the npm of distube since the lavalink was not working for me and before distube dinteraction.options.getMember() not definable?Somehow `interaction.options.getMember()` is not valid... While on the Discord.js docs it is. I alreWould there be a way to make a command list?How would I make a command list, for example you would use !help (or !help <commandName>) (exampleClear Command Cache?Since the other one removed his message... How to clear the cache using Sapphire?InteractionHandler ButtonsI have a problem with my buttons. Somehow they don't work... I guess it's something easy, but I can'ValidationError: Expected a string primitive```ts C:\Users\ItzEx\OneDrive\Desktop\Projects\TicketPulse\node_modules\@sapphire\shapeshift\src\val