#Interaction not responding upon button click

31 messages · Page 1 of 1 (latest)

queen oxide
#

Interaction not responding upon button click

#

Clearly my response is wrong somewhere...

digital thicket
#

clicking on button will emit interaction with MessageComponent type

split wyvernBOT
#

      func (i Interaction) MessageComponentData() (data MessageComponentInteractionData)
    ```
MessageComponentData is helper function to assert the inner InteractionData to MessageComponentInteractionData. Make sure to check that the Type of the interaction is InteractionMessageComponent before calling.
queen oxide
#

Guess I still dont quite understand it..

queen oxide
#

There has to be a somewhat simpler way than what I have it code as at the moment..

slate lagoon
#

do you understand why you're getting the ignore print that you're getting?

#

( @queen oxide )

queen oxide
slate lagoon
#

you're only handling application command interactions. buttons are not those.

#

like darp said, you get a message component interaction when a button is pressed.

queen oxide
#

I do understand that, I do have a setup with component handlers and command handlers (like the bwmarrin git examples/components.go) as well.

slate lagoon
#

ok, but your switch only has a single case of type discordgo.InteractionApplicationCommand.

#

discordgo.InteractionApplicationCommand is not the type of interaction generated by a button press.

digital thicket
#

please note that Buttons with link style never generate interaction

queen oxide
#

Received, I’ll dig more.
Thanks yall!

queen oxide
#

well that is not it facepalm

queen oxide
#

Clicking the next button makes another next button appear.

digital thicket
#

code?

queen oxide
#

I have no idea where to begin on which code to send honestly...

#

I have played with this so much its crazy.

#

Actually... gonna be this code

"help_next": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
            err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
                Type: discordgo.InteractionResponseChannelMessageWithSource,
                Data: &discordgo.InteractionResponseData{
                    Components: []discordgo.MessageComponent{
                        discordgo.ActionsRow{
                            Components: []discordgo.MessageComponent{
                                discordgo.Button{
                                    Emoji: discordgo.ComponentEmoji{
                                        Name: "➡",
                                    },
                                    Label:    "Next",
                                    Style:    discordgo.PrimaryButton,
                                    CustomID: "help_next",
                                    Disabled: page == totalPages()-1,
                                },
                            },
                        },
                    },
                    Flags: discordgo.MessageFlagsEphemeral,
                },
            })
            if err != nil {
                panic(err)
            }
        },
#

I just added the ephemeral flag after the screenshot

slate lagoon
#

i mean…isn’t that what the code you pasted does?

#

do you not understand why what you posted produces another button? have you tried walking through what executes in your code (e.g. with prints or a debugger)?

#

on receiving an interaction with ID help_next, you’re sending a response with an action row with one component: a button that says next, and when clicked, sends an interaction with ID help_next.

#

that’s the code you wrote. do you agree?

#

it feels to me like you’re having some trouble understanding your own code, and it’s really hard for us to provide any meaningful help when that’s the case.