Build each user a unique sets of buttons

This is the link. https://discordjs.guide/message-components/buttons.html#building-buttons I am just wondering how I can build a unique sets of buttons for each user. For instance, if a user type in a slash command such as /option, then a set of buttons like the above link shows will pop up. But those buttons belong uniquely to the user who triggers it and not to be shared. Cuz I built one like that before, but if one user uses it, it is fine, but if two or more users use it, then the variable that is set by the first user after clicking the button to set the value and put that into a variable will be overridden by the second user. In other word, a set of buttons are shared among users and it does not matter who triggers it.
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
40 Replies
d.js toolkit
d.js toolkit6mo ago
- 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!
Amgelo
Amgelo6mo ago
can you share your code? buttons aren't "shared" anywhere (nor builders), at least not by djs if you're doing it the way the guide says, they (builders) are created only on that command execution and garbage collected after that what you're experiencing sounds like you're storing some state in a variable, and you're reusing the same variable for every button click, regardless of user which has nothing to do with buttons
Kenryuakuma
KenryuakumaOP6mo ago
Sorry I am not a real coder. The code is pretty messy. I apologize
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kenryuakuma
KenryuakumaOP6mo ago
Thx just wonder how I implement it. I use ephemeral message
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kenryuakuma
KenryuakumaOP6mo ago
Would ya mind showing me the code to check the user if possible?
d.js docs
d.js docs6mo ago
:property: ButtonInteraction#user @14.15.2 The user who created this interaction :property: ChatInputCommandInteraction#user @14.15.2 The user who created this interaction
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs6mo ago
:property: User#id @14.15.2 The user's id
Kenryuakuma
KenryuakumaOP6mo ago
Thx will try it how much text can we put into the slash option choice command?
name: "description",
description: "The description of the resource you want to post",
type: ApplicationCommandOptionType.String,
required: true,
name: "description",
description: "The description of the resource you want to post",
type: ApplicationCommandOptionType.String,
required: true,
It seems that If I put two long paragraphs into it I get the error message. node:events:496 throw er; // Unhandled 'error' event ^ CombinedPropertyError: Received one or more errors
Emitted 'error' event on Client instance at: at emitUnhandledRejectionOrErr (node:events:401:10) at process.processTicksAndRejections (node:internal/process/task_queues:84:21) { errors: [ [ 0, CombinedPropertyError: Received one or more errors at _ObjectValidator.handleIgnoreStrategy (/home/runner/Bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1273:72) at _ObjectValidator.handleStrategy (/home/runner/Bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1143:47) at _ObjectValidator.handle (/home/runner/Bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1243:17) at _ObjectValidator.run (/home/runner/Bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:202:23) at _ArrayValidator.handle (/home/runner/Bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:474:37) at _ArrayValidator.parse (/home/runner/Bot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:216:88) at EmbedBuilder.addFields (/home/runner/Bot/node_modules/@discordjs/builders/dist/index.js:225:31) at Client.<anonymous> (file:///home/runner/Bot/index.js:146:10) at Client.emit (node:events:518:28) at InteractionCreateAction.handle (/home/runner/Bot/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12) { errors: [ [ 'value', [ExpectedConstraintError] ] ] } ] ] }
Amgelo
Amgelo6mo ago
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Amgelo
Amgelo6mo ago
up to 100 characters
Kenryuakuma
KenryuakumaOP6mo ago
Is there a way to intervene this?
Amgelo
Amgelo6mo ago
no that's just how discord works
Kenryuakuma
KenryuakumaOP6mo ago
I see. For all Embed right?
Amgelo
Amgelo6mo ago
we're talking about command choices, not embeds
Kenryuakuma
KenryuakumaOP6mo ago
Yup that is what happens when I put a bunch of texts in the slash commmand options. I put a three full paragraphs into the description, and then it generated the errors
No description
Amgelo
Amgelo6mo ago
oh, you mean how much you can send?
Kenryuakuma
KenryuakumaOP6mo ago
Yup brother
Amgelo
Amgelo6mo ago
I'm not sure about that limit, but it wouldn't throw an error to you
Kenryuakuma
KenryuakumaOP6mo ago
If I put like a few sentences, it works fine.
Amgelo
Amgelo6mo ago
if it does maybe it's because you sent a description that's too long, you could cut down what you receive
d.js docs
d.js docs6mo ago
:discord: Channels Resource > Embed Object read more
Amgelo
Amgelo6mo ago
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Kenryuakuma
KenryuakumaOP6mo ago
The option type I put in is a string. type: ApplicationCommandOptionType.String,
Amgelo
Amgelo6mo ago
the description limit is 4096 characters it doesn't have to do with that though now that I look at your error, it says it's erroring on addFields not setDescription could you send the whole error? through a bin
d.js docs
d.js docs6mo ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
Kenryuakuma
KenryuakumaOP6mo ago
sure
Kenryuakuma
KenryuakumaOP6mo ago
Pastebin
node:events:496 throw er; // Unhandled 'error' event ^Com...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Amgelo
Amgelo6mo ago
is that the whole error? could you show your index.js, around line 146?
Kenryuakuma
KenryuakumaOP6mo ago
Yup
Kenryuakuma
KenryuakumaOP6mo ago
No description
Kenryuakuma
KenryuakumaOP6mo ago
Pastebin
import { Client, IntentsBitField } from "discord.js";import { Butt...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Kenryuakuma
KenryuakumaOP6mo ago
Like I said bro, I am not a professional or a real coder, I am still learning lol please bear with me thanks.
Amgelo
Amgelo6mo ago
* don't use the raw options.get("name").value, use options.getString("name") (since it's a string option), you can also use getUser if it was a user option (and you get the full User object), getChannel if it was a channel and so on, something you wouldn't be able to do directly with the raw value * on your addFields, make sure description, audio and subtitle aren't undefined. if they're meant to be optional, either check they were specified before adding them or include a default value like "Not specified" or whatever suits your needs
Kenryuakuma
KenryuakumaOP6mo ago
Those are required values. But thanks
Amgelo
Amgelo6mo ago
make sure they fall inside the field limits then ^^ field values can only have up to 1024 characters you could cut the text before trying to add it
d.js docs
d.js docs6mo ago
:mdn: String.prototype.slice() The slice() method of String values extracts a section of this string and returns it as a new string, without modifying the original string.
Kenryuakuma
KenryuakumaOP6mo ago
Thanks here is the second file https://pastebin.com/T1Ey7VkA
Pastebin
import dotenv from "dotenv";import { REST, Routes, ApplicationComma...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Want results from more Discord servers?
Add your server