Skip to content

Commit

Permalink
feat(SelectMenu): default values (#1452)
Browse files Browse the repository at this point in the history
* feat(SelectMenu): default values

* fix: remove unncessary pointer

Since SelectMenu is used as a nested structure, it is not possible to
partially edit it. Thus, an empty slice does not need to be accounted for,
and the pointer, which would only be omitted if the value is nil, can be
converted to a regular slice.

* fix: correct grammar in the comment to SelectMenuDefaultValueType
  • Loading branch information
FedorLap2006 authored Dec 8, 2023
1 parent 44e4acb commit 0068a2d
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions components.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ type SelectMenuOption struct {
Default bool `json:"default"`
}

// SelectMenuDefaultValueType represents the type of an entity selected by default in auto-populated select menus.
type SelectMenuDefaultValueType string

// SelectMenuDefaultValue types.
const (
SelectMenuDefaultValueUser SelectMenuDefaultValueType = "user"
SelectMenuDefaultValueRole SelectMenuDefaultValueType = "role"
SelectMenuDefaultValueChannel SelectMenuDefaultValueType = "channel"
)

// SelectMenuDefaultValue represents an entity selected by default in auto-populated select menus.
type SelectMenuDefaultValue struct {
// ID of the entity.
ID string `json:"id"`
// Type of the entity.
Type SelectMenuDefaultValueType `json:"type"`
}

// SelectMenuType represents select menu type.
type SelectMenuType ComponentType

Expand All @@ -198,9 +216,13 @@ type SelectMenu struct {
MinValues *int `json:"min_values,omitempty"`
// This value determines the maximal amount of selected items in the menu.
// If MaxValues or MinValues are greater than one then the user can select multiple items in the component.
MaxValues int `json:"max_values,omitempty"`
Options []SelectMenuOption `json:"options,omitempty"`
Disabled bool `json:"disabled"`
MaxValues int `json:"max_values,omitempty"`
// List of default values for auto-populated select menu.
// NOTE: Number of entries should be in the range defined by MinValues and MaxValues.
DefaultValues []SelectMenuDefaultValue `json:"default_values,omitempty"`

Options []SelectMenuOption `json:"options,omitempty"`
Disabled bool `json:"disabled"`

// NOTE: Can only be used in SelectMenu with Channel menu type.
ChannelTypes []ChannelType `json:"channel_types,omitempty"`
Expand Down

0 comments on commit 0068a2d

Please sign in to comment.