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

Slash commands example: parse options into a map #1129

Merged
merged 7 commits into from Apr 4, 2022
Merged

Slash commands example: parse options into a map #1129

merged 7 commits into from Apr 4, 2022

Conversation

switchupcb
Copy link
Contributor

#1126 Method 3

The resulting example output:
image

image

@switchupcb
Copy link
Contributor Author

If options can be recursive, we can implement that to the existing loop while unmarshalling. Otherwise, this should be good to go!

@FedorLap2006 FedorLap2006 linked an issue Mar 10, 2022 that may be closed by this pull request
@switchupcb
Copy link
Contributor Author

If the subcommand example is correct, there can be parsed recursive options. However, they can't have the same name as other options. I will implement a recursive parse and example tomorrow.

@FedorLap2006 FedorLap2006 changed the title add OptionMap field to ApplicationCommandInteractionDataOption Add OptionMap to Application command data Mar 12, 2022
@switchupcb
Copy link
Contributor Author

image
image
image
image

@switchupcb switchupcb marked this pull request as draft March 13, 2022 03:44
@switchupcb switchupcb marked this pull request as ready for review March 13, 2022 03:44
Copy link
Collaborator

@FedorLap2006 FedorLap2006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said in the original issue, DiscordGo is 1:1 mapping of Discord API. I don't think that adding an extra option, which would be just a reflection of the original, is a good idea.
That said, I think it would fair to still showcase parsing options into a map in the example.

Additionally, note my comments.

examples/slash_commands/main.go Outdated Show resolved Hide resolved
examples/slash_commands/main.go Outdated Show resolved Hide resolved
examples/slash_commands/main.go Outdated Show resolved Hide resolved
removes parseMap from the API and requires user inclusion
@FedorLap2006 FedorLap2006 changed the title Add OptionMap to Application command data Slash commands example: parse options into a map Mar 29, 2022
@FedorLap2006 FedorLap2006 merged commit 0c27ced into bwmarrin:master Apr 4, 2022
@switchupcb switchupcb deleted the map-pr branch April 4, 2022 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Options Handling to Reduce Security Errors
2 participants