mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-01-08 13:07:43 +00:00
discord: Add AutocompleteOptions type & Find()
This commit is contained in:
parent
15c37ad341
commit
b01675ab92
|
@ -175,7 +175,27 @@ type AutocompleteInteraction struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
CommandType CommandType `json:"type"`
|
CommandType CommandType `json:"type"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Options []AutocompleteOption `json:"options"`
|
Options AutocompleteOptions `json:"options"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type implements ComponentInteraction.
|
||||||
|
func (*AutocompleteInteraction) InteractionType() InteractionDataType {
|
||||||
|
return AutocompleteInteractionType
|
||||||
|
}
|
||||||
|
func (*AutocompleteInteraction) data() {}
|
||||||
|
|
||||||
|
// AutocompleteOptions is a list of autocompletion options.
|
||||||
|
// Use `Find` to get your named autocompletion option.
|
||||||
|
type AutocompleteOptions []AutocompleteOption
|
||||||
|
|
||||||
|
// Find returns the named autocomplete option.
|
||||||
|
func (o AutocompleteOptions) Find(name string) AutocompleteOption {
|
||||||
|
for _, opt := range o {
|
||||||
|
if strings.EqualFold(opt.Name, name) {
|
||||||
|
return opt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AutocompleteOption{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutocompleteOption is an autocompletion option in an AutocompleteInteraction.
|
// AutocompleteOption is an autocompletion option in an AutocompleteInteraction.
|
||||||
|
@ -191,7 +211,6 @@ type AutocompleteOption struct {
|
||||||
func (*AutocompleteInteraction) InteractionType() InteractionDataType {
|
func (*AutocompleteInteraction) InteractionType() InteractionDataType {
|
||||||
return AutocompleteInteractionType
|
return AutocompleteInteractionType
|
||||||
}
|
}
|
||||||
func (*AutocompleteInteraction) data() {}
|
|
||||||
|
|
||||||
// ComponentInteraction is a union component interaction response types. The
|
// ComponentInteraction is a union component interaction response types. The
|
||||||
// types can be whatever the constructors for this type will return.
|
// types can be whatever the constructors for this type will return.
|
||||||
|
|
Loading…
Reference in a new issue