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

feat(interaction): Add GetOption method on Application Interaction Command #1535

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,18 @@
TargetID string `json:"target_id"`
}

// Get the interaction data option by name

Check failure on line 329 in interactions.go

View workflow job for this annotation

GitHub Actions / lint

comment on exported method `ApplicationCommandInteractionData.GetOption` should be of the form `GetOption ...` (golint)
func (d ApplicationCommandInteractionData) GetOption(name string) (option *ApplicationCommandInteractionDataOption) {
FedorLap2006 marked this conversation as resolved.
Show resolved Hide resolved
for _, opt := range d.Options {
if opt.Name == name {
option = opt
break
}
}

return
}

// ApplicationCommandInteractionDataResolved contains resolved data of command execution.
// Partial Member objects are missing user, deaf and mute fields.
// Partial Channel objects only have id, name, type and permissions fields.
Expand Down Expand Up @@ -408,6 +420,18 @@
Focused bool `json:"focused,omitempty"`
}

// Get the interaction data option by name

Check failure on line 423 in interactions.go

View workflow job for this annotation

GitHub Actions / lint

comment on exported method `ApplicationCommandInteractionDataOption.GetOption` should be of the form `GetOption ...` (golint)
func (o ApplicationCommandInteractionDataOption) GetOption(name string) (option *ApplicationCommandInteractionDataOption) {
for _, opt := range o.Options {
if opt.Name == name {
option = opt
break
}
}

return
}

// IntValue is a utility function for casting option value to integer
func (o ApplicationCommandInteractionDataOption) IntValue() int64 {
if o.Type != ApplicationCommandOptionInteger {
Expand Down
Loading