Edit message according to selected value
Hello,
I've created an embed and a selectMenu just below it and I'd like to modify the embed (and therefore the message) according to the value chosen.
I've tried something but it doesn't work
Could you please help me?
(I don't know if my explanation is very clear, so I've tried to schematize it in the attachment with the code.)
27 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!Do you get a error or something?
This is because I put "
if (Option === 'commands') {
" but I don't know how to retrieve the previous value.ah I see. If you want to make the select menu available for any period of time after command usage you need a listener, otherwise you need a handler for select menus. The method to call the select menu is
interaction.values[0]
for example:
okay, i'll try this
I want to do something like this
It will be possible with this method
I'm sorry if I'm not clear in my explanations, but I can't describe exactly what I want (+I use a translator to talk to you).
yes because with
interaction.customId
you ask for the Id from the select menu and with interaction.values[0]
you ask for the first input from the select menuOkay, thanks, I'll do that and let you know if it works.
*My diagram is really unclear π’ *
so you can ask for:
Isn't it
interaction.editReply
to edit a message?
And do I need to redo an entire embed to modify the first one, or can I just modify certain values (like the name, fields)?I've done this but it doesn't work (I think it's because I'm defining a new embed).
Please let me know when you return.
It returns nothing right?
you need a listener or handler for the select menu, you use a slash command handler for the slash command, the same you need for select menus
Only this
(Interaction failure in french)
How do I do this in my code?
Sorry but I'm looking in the doc but I can't find it.
put in your main file:
client.on('interactionCreate', async interaction => {
[select Menu code]
}
for the first its enoughHere is the main file (and the startup file as well)
I can put this piece of code anywhere in it ?
All right, I'll try it this way
Is there any reason why we can't put this piece of code in the help.js file (the bot's command) directly (instead of the main file, because I try to keep it to a minimum)?
And since we've put the code in this file, I can delete it from the other one (help.js).
you can put it in with an listener, but this is only temporary. A other possibility is, that you create a select menu handler, what this is, you can search in the internet
yes
What do you mean by "temporary"?
And okay, I'll do my research on that, but for now I'll leave this bit of code in the main file.
And thank you very much, everything works as expected β€οΈ
no problem
like you have for example 30mins to select something or when the bot restart you need to make the command again to click something in the select menu
I hope you understand what I say because Iβm german and dont talk very well english xD
Okay, I understand.
Yes, I understand what you've explained to me, but the hardest part was for you to understand me xD (I'm French, so I don't speak English well).