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
- 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!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
Sorry I am not a real coder. The code is pretty messy. I apologize
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
Thx just wonder how I implement it.
I use ephemeral message
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
Would ya mind showing me the code to check the user if possible?
:property: ButtonInteraction#user
@14.15.2
The user who created this interaction
:property: ChatInputCommandInteraction#user @14.15.2
The user who created this interactionUnknown User•7mo ago
Message Not Public
Sign In & Join Server To View
Thx will try it
how much text can we put into the slash option choice command?
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] ] ] } ] ] }
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] ] ] } ] ] }
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.
up to 100 characters
Is there a way to intervene this?
no
that's just how discord works
I see. For all Embed right?
we're talking about command choices, not embeds
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
oh, you mean how much you can send?
Yup
brother
I'm not sure about that limit, but it wouldn't throw an error to you
If I put like a few sentences, it works fine.
if it does maybe it's because you sent a description that's too long, you could cut down what you receive
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.
The option type I put in is a string. type: ApplicationCommandOptionType.String,
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
sure
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.
is that the whole error?
could you show your index.js, around line 146?
Yup
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.
Like I said bro, I am not a professional or a real coder, I am still learning lol please bear with me thanks.
* 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 needsThose are required values. But thanks
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
: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.
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.