Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactions: the Buttons #933

Merged
merged 33 commits into from Jun 27, 2021
Merged

Conversation

FedorLap2006
Copy link
Collaborator

Hello everyone. Just finished implementing buttons functionality for DiscordGo. Looking forward a feedback.

interactions.go Outdated Show resolved Hide resolved
components.go Outdated Show resolved Hide resolved
@FedorLap2006 FedorLap2006 changed the title The Interactions: Buttons Interactions: the Buttons May 17, 2021
interactions.go Outdated Show resolved Hide resolved
@FedorLap2006
Copy link
Collaborator Author

After some discussion about InteractionData. I'd say that we decided to separate data into different structures. And I personally decided to make it an interface. So, waiting for feedback!

interactions.go Outdated Show resolved Hide resolved
@FedorLap2006
Copy link
Collaborator Author

Hello everyone. It seems that documentation has been published and the buttons are ungated. I think It's time to mark this PR as ready for review. Well, enjoy the buttons!

@FedorLap2006 FedorLap2006 marked this pull request as ready for review May 26, 2021 22:15
interactions.go Outdated Show resolved Hide resolved
@yyewolf
Copy link

yyewolf commented May 28, 2021

You can add the "Component" feature to these endpoints :

https://discord.com/developers/docs/resources/webhook#edit-webhook-message
https://discord.com/developers/docs/resources/webhook#execute-webhook
https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response

They all support perfectly fine components objects and are needed to put buttons on a follow up message for example.

components.go Outdated Show resolved Hide resolved
@mcdearman
Copy link

mcdearman commented Jun 22, 2021

My command router which just operates off of a MessageCreate handler breaks with this PR with the following trace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x71daff]

goroutine 56 [running]:
github.com/bwmarrin/discordgo.(*Message).UnmarshalJSON(0x0, 0xc000438600, 0x2c3, 0x300, 0x0, 0x0)
        /home/chris/go/pkg/mod/github.com/!fedor!lap2006/discordgo@v0.22.1-0.20210619182440-23a197a98005/message.go:144 +0x9f
encoding/json.(*decodeState).object(0xc000284420, 0xa0d840, 0xc000010218, 0x16, 0xc000284448, 0xc0000f9d7b)
        /home/chris/go/src/encoding/json/decode.go:609 +0x20a3
encoding/json.(*decodeState).value(0xc000284420, 0xa0d840, 0xc000010218, 0x16, 0xc0000f9d68, 0x524285)
        /home/chris/go/src/encoding/json/decode.go:370 +0x6d
encoding/json.(*decodeState).unmarshal(0xc000284420, 0xa0d840, 0xc000010218, 0xc000284448, 0x0)
        /home/chris/go/src/encoding/json/decode.go:180 +0x1f4
encoding/json.Unmarshal(0xc000438600, 0x2c3, 0x300, 0xa0d840, 0xc000010218, 0x1, 0x0)
        /home/chris/go/src/encoding/json/decode.go:107 +0x11a
github.com/bwmarrin/discordgo.(*Session).onEvent(0xc00024ae00, 0x1, 0xc00001a400, 0x2eb, 0x400, 0x0, 0x0, 0x0)
        /home/chris/go/pkg/mod/github.com/!fedor!lap2006/discordgo@v0.22.1-0.20210619182440-23a197a98005/wsapi.go:584 +0xf65
github.com/bwmarrin/discordgo.(*Session).listen(0xc00024ae00, 0xc0003609a0, 0xc0004f2480)
        /home/chris/go/pkg/mod/github.com/!fedor!lap2006/discordgo@v0.22.1-0.20210619182440-23a197a98005/wsapi.go:250 +0x7e
created by github.com/bwmarrin/discordgo.(*Session).Open
        /home/chris/go/pkg/mod/github.com/!fedor!lap2006/discordgo@v0.22.1-0.20210619182440-23a197a98005/wsapi.go:202 +0xbc5
exit status 2

@FedorLap2006
Copy link
Collaborator Author

My command router which just operates off of a MessageCreate handler breaks with this PR with the following trace:

@ChrisMcDearman Should be fixed now.

@phenpessoa phenpessoa mentioned this pull request Jun 22, 2021
components.go Outdated Show resolved Hide resolved
components.go Outdated Show resolved Hide resolved
@CarsonHoffman
Copy link
Collaborator

Outside of a few outstanding small things, this is looking quite solid to me; the API surface is definitely cleaner than at the start. Not to jinx it, but as long as nothing else comes up in the near future, I'm excited to get this merged in! 🤠

@FedorLap2006
Copy link
Collaborator Author

FedorLap2006 commented Jun 23, 2021

I agree with @CarsonHoffman - this is pretty much it. But if anyone wanna give additional review/feedback, feel free to, at least until Carson will merge it 🤠

@FedorLap2006
Copy link
Collaborator Author

Oh, yeah, forgot about them!

@CarsonHoffman CarsonHoffman merged commit 421e149 into bwmarrin:master Jun 27, 2021
@FedorLap2006
Copy link
Collaborator Author

FedorLap2006 commented Jun 27, 2021

Thanks everyone for contribution and feedbacks. And special thanks @CarsonHoffman for his patience and reviews! 🚀

@0xTenzo
Copy link

0xTenzo commented Jul 11, 2021

Thanks for this!

Could we get some comments in https://github.com/bwmarrin/discordgo/blob/master/examples/components/main.go about how to use this / what it does?

It's not immediately clear what this new interactions functionality is, or what we are supposed to see when running the example. After attempting it, I was met with:

Cannot create slash command: HTTP 403 Forbidden, {"message": "Missing Access", "code": 50001}.

Are there some prerequisite permissions that the bot needs? If so, a comment on adding them would be great.

FedorLap2006 added a commit to FedorLap2006/discordgo that referenced this pull request Jul 30, 2021
* Interactions: buttons

* Doc fix

* Gofmt fix

* Fix typo

* Remaking interaction data into interface

* Godoc fix

* Gofmt fix

* Godoc fix

* InteractionData helper functions and some fixes in slash commands example

* Fix components example

* Yet another fix of components example

* Fix interaction unmarshaling

* Gofmt fix

* Godoc fix

* Gofmt fix

* Corrected naming and docs

* Rolled back API version

* Requested fixes

* Added support of components to webhook and regular messages

* Fix components unmarshaling

* Godoc fix

* Requested fixes

* Fixed unmarshaling issues

* Components example: cleanup

* Added components tracking to state

* Requested fixes

* Renaming fix

* Remove more named returns

* Minor English fixes

Co-authored-by: Carson Hoffman <c@rsonhoffman.com>
CarsonHoffman added a commit that referenced this pull request Aug 9, 2021
* Interactions: the Buttons (#933)

* Interactions: buttons

* Doc fix

* Gofmt fix

* Fix typo

* Remaking interaction data into interface

* Godoc fix

* Gofmt fix

* Godoc fix

* InteractionData helper functions and some fixes in slash commands example

* Fix components example

* Yet another fix of components example

* Fix interaction unmarshaling

* Gofmt fix

* Godoc fix

* Gofmt fix

* Corrected naming and docs

* Rolled back API version

* Requested fixes

* Added support of components to webhook and regular messages

* Fix components unmarshaling

* Godoc fix

* Requested fixes

* Fixed unmarshaling issues

* Components example: cleanup

* Added components tracking to state

* Requested fixes

* Renaming fix

* Remove more named returns

* Minor English fixes

Co-authored-by: Carson Hoffman <c@rsonhoffman.com>

* Doc fix

* Gofmt fix

* Fix typo

* Remaking interaction data into interface

* Godoc fix

* Gofmt fix

* Godoc fix

* InteractionData helper functions and some fixes in slash commands example

* Fix components example

* Yet another fix of components example

* Fix interaction unmarshaling

* Godoc fix

* Gofmt fix

* Corrected naming and docs

* Rolled back API version

* Requested fixes

* Added support of components to webhook and regular messages

* Interactions: select menus

* Example fix

* Merge fix

* Some fixes

* Added missing documentation

* Fix components unmarshaling

* Godoc fix

* Requested fixes

* Fixed unmarshaling issues

* Components example: cleanup

* Gofmt fix

* Godoc fix

* URL field renaming fix

* Added flags to followups

* Updated components example

* Fixed typo in components example

* Merge fix

* Improve handling of invalid interaction situations

* support allowing webhook edits with files, and responding to interactions with files (#931)

* allow files in webhook message edits

* add Files to WebhookEdit struct

* move the construction of the multipart body for files into a shared function

* allow  interaction responses to have files

* go fmt

* fix err shadowing

* document MakeFilesBody

* rename MakeFilesBody -> EncodeWithFiles. fix InteractionRespond responding twice

* use resp in InteractionRespond files, add basic-command-with-files example command

* import strings and go fmt

* EncodeWithFiles -> MultiPartBodyWithJSON

* go fmt

* fix example for slash_commands

* move files to responsedata

* Merge fixes

* Fixed rebase consequences

Co-authored-by: Carson Hoffman <c@rsonhoffman.com>
Co-authored-by: plally <pierce@vulpes.dev>
jccit pushed a commit to jccit/discordgo that referenced this pull request Sep 14, 2021
* Interactions: buttons

* Doc fix

* Gofmt fix

* Fix typo

* Remaking interaction data into interface

* Godoc fix

* Gofmt fix

* Godoc fix

* InteractionData helper functions and some fixes in slash commands example

* Fix components example

* Yet another fix of components example

* Fix interaction unmarshaling

* Gofmt fix

* Godoc fix

* Gofmt fix

* Corrected naming and docs

* Rolled back API version

* Requested fixes

* Added support of components to webhook and regular messages

* Fix components unmarshaling

* Godoc fix

* Requested fixes

* Fixed unmarshaling issues

* Components example: cleanup

* Added components tracking to state

* Requested fixes

* Renaming fix

* Remove more named returns

* Minor English fixes

Co-authored-by: Carson Hoffman <c@rsonhoffman.com>
jccit pushed a commit to jccit/discordgo that referenced this pull request Sep 14, 2021
* Interactions: the Buttons (bwmarrin#933)

* Interactions: buttons

* Doc fix

* Gofmt fix

* Fix typo

* Remaking interaction data into interface

* Godoc fix

* Gofmt fix

* Godoc fix

* InteractionData helper functions and some fixes in slash commands example

* Fix components example

* Yet another fix of components example

* Fix interaction unmarshaling

* Gofmt fix

* Godoc fix

* Gofmt fix

* Corrected naming and docs

* Rolled back API version

* Requested fixes

* Added support of components to webhook and regular messages

* Fix components unmarshaling

* Godoc fix

* Requested fixes

* Fixed unmarshaling issues

* Components example: cleanup

* Added components tracking to state

* Requested fixes

* Renaming fix

* Remove more named returns

* Minor English fixes

Co-authored-by: Carson Hoffman <c@rsonhoffman.com>

* Doc fix

* Gofmt fix

* Fix typo

* Remaking interaction data into interface

* Godoc fix

* Gofmt fix

* Godoc fix

* InteractionData helper functions and some fixes in slash commands example

* Fix components example

* Yet another fix of components example

* Fix interaction unmarshaling

* Godoc fix

* Gofmt fix

* Corrected naming and docs

* Rolled back API version

* Requested fixes

* Added support of components to webhook and regular messages

* Interactions: select menus

* Example fix

* Merge fix

* Some fixes

* Added missing documentation

* Fix components unmarshaling

* Godoc fix

* Requested fixes

* Fixed unmarshaling issues

* Components example: cleanup

* Gofmt fix

* Godoc fix

* URL field renaming fix

* Added flags to followups

* Updated components example

* Fixed typo in components example

* Merge fix

* Improve handling of invalid interaction situations

* support allowing webhook edits with files, and responding to interactions with files (bwmarrin#931)

* allow files in webhook message edits

* add Files to WebhookEdit struct

* move the construction of the multipart body for files into a shared function

* allow  interaction responses to have files

* go fmt

* fix err shadowing

* document MakeFilesBody

* rename MakeFilesBody -> EncodeWithFiles. fix InteractionRespond responding twice

* use resp in InteractionRespond files, add basic-command-with-files example command

* import strings and go fmt

* EncodeWithFiles -> MultiPartBodyWithJSON

* go fmt

* fix example for slash_commands

* move files to responsedata

* Merge fixes

* Fixed rebase consequences

Co-authored-by: Carson Hoffman <c@rsonhoffman.com>
Co-authored-by: plally <pierce@vulpes.dev>
@FedorLap2006 FedorLap2006 added this to the v0.24.0 milestone Feb 27, 2022
@FedorLap2006 FedorLap2006 added the feature Feature implementation label Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet