#this stuff exactly
1 messages · Page 1 of 1 (latest)
I tried to, but I don't know how to get user's choice, because I add options in .forEach()
so basically I want to make an edit of embed after user chooses an option, but I also want to know his choice, because I have array in my database, in which I store "shops" and in this dropdown I did .forEach() which add all that I have in "shop" array in options. Therefore it's quite hard for me to 1) find out user's choice 2) work with it choice, because each item in array has it's name
So if for example user chooses Shop2, it will edit embed and show all that Shop2 array stores.
@south wharf so I need a help with that
I hope you understood
I understood, my energy was gone for a couple minutes, I'm back now
alright
Are you collecting button interactions?
what do you mean exactly?
Like, when a user sends a command interaction, you collect it and then execute it, right?
basically yes
You have to do the same for buttons
okay, is there any example how it works in case of buttons?
if (e.isButton()) {
try {
} catch (error) {}
}
e for interaction, wait a bit I'll find out
By the way, are you sure that it's about buttons? I have dropdown select menu, but as I know, buttons are a bit another thing
Oh
It's a context menu, right?
It called "Select menus"
alr
Something is wrong when I try the condition I sent, trying to find out what it is to continue
Okay
if (e.isSelectMenu()) {
let selectMenu = e
if (selectMenu) {
try {
await e.update({
content: "A component interaction was received",
components: []
})
} catch (error) {
console.error(error)
await e.reply({
content: `Tried to edit message and failed.`,
ephemeral: true,
})
}
}
}
You can try that, it'll edit the reply to message I think that's a good starting point
yeah, but it's not that I need rn
I have that already, but didn't use because I have the main problem
I want to receive the choice of user
I have already described it here
So I need firstly to find out what exactly did he choose and then work with this choice
You wanna change the items in the select menu when the user clicks an item then
That's better
Please read carefully what have I written
I don’t have exact value name like in example
I have .forEach() which gets values from array and for me it’s unknown which value has item which user will choose
So I can’t make if (selected === “ping”)
Because I don’t know what to write instead of “ping”
That’s why I’m trying to find help
Sir
This is easy to handle, create a new async function to update the embed then call it in your interaction handling code
If you need any help you can call me later, it's literally just adding handling for your modal submit
if (e.isModalSubmit()) {
let ID = e.customId,
customIds = this.customIds
if (ID.includes(customIds.gamesId)) {
if (ID.includes(customIds.modalId)) {
let command = e.client.interactions.get(
ID.slice(customIds.gamesId.length, -customIds.modalId.length),
)
if (command) {
try {
await command.modal(e)
} catch (error) {
console.error(error)
await e.reply({
content: `Tried to execute ${ID.slice(
customIds.gamesId.length,
-customIds.modalId.length,
)} and it didn't work.`,
ephemeral: true,
})
}
}
}
}
}