#this stuff exactly

1 messages · Page 1 of 1 (latest)

south wharf
#

Are you editing the message after you add an option?

coral field
#

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

south wharf
#

I understood, my energy was gone for a couple minutes, I'm back now

coral field
#

alright

south wharf
#

Are you collecting button interactions?

coral field
#

what do you mean exactly?

south wharf
#

Like, when a user sends a command interaction, you collect it and then execute it, right?

coral field
#

basically yes

south wharf
#

You have to do the same for buttons

coral field
#

okay, is there any example how it works in case of buttons?

south wharf
#
        if (e.isButton()) {
            try {
            } catch (error) {}
        }
#

e for interaction, wait a bit I'll find out

coral field
#

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

south wharf
#

Oh

coral field
#

buttons look like that

#

I have this one

south wharf
#

It's a context menu, right?

coral field
#

It called "Select menus"

south wharf
#

Then

if (e.isSelectMenu()) {
            try {
            } catch (error) {}
        }
#

just a sec

coral field
#

alr

south wharf
#

Something is wrong when I try the condition I sent, trying to find out what it is to continue

coral field
#

Okay

south wharf
#
        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

coral field
#

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

coral field
#

So I need firstly to find out what exactly did he choose and then work with this choice

south wharf
#

You wanna change the items in the select menu when the user clicks an item then

#

That's better

coral field
#

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

south wharf
#

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,
              })
            }
          }
        }
      }
    }