aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/bwmarrin/discordgo/components.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/bwmarrin/discordgo/components.go')
-rw-r--r--vendor/github.com/bwmarrin/discordgo/components.go46
1 files changed, 36 insertions, 10 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/components.go b/vendor/github.com/bwmarrin/discordgo/components.go
index 6ee4e28..a5f86b3 100644
--- a/vendor/github.com/bwmarrin/discordgo/components.go
+++ b/vendor/github.com/bwmarrin/discordgo/components.go
@@ -10,10 +10,14 @@ type ComponentType uint
// MessageComponent types.
const (
- ActionsRowComponent ComponentType = 1
- ButtonComponent ComponentType = 2
- SelectMenuComponent ComponentType = 3
- TextInputComponent ComponentType = 4
+ ActionsRowComponent ComponentType = 1
+ ButtonComponent ComponentType = 2
+ SelectMenuComponent ComponentType = 3
+ TextInputComponent ComponentType = 4
+ UserSelectMenuComponent ComponentType = 5
+ RoleSelectMenuComponent ComponentType = 6
+ MentionableSelectMenuComponent ComponentType = 7
+ ChannelSelectMenuComponent ComponentType = 8
)
// MessageComponent is a base interface for all message components.
@@ -41,7 +45,8 @@ func (umc *unmarshalableMessageComponent) UnmarshalJSON(src []byte) error {
umc.MessageComponent = &ActionsRow{}
case ButtonComponent:
umc.MessageComponent = &Button{}
- case SelectMenuComponent:
+ case SelectMenuComponent, ChannelSelectMenuComponent, UserSelectMenuComponent,
+ RoleSelectMenuComponent, MentionableSelectMenuComponent:
umc.MessageComponent = &SelectMenu{}
case TextInputComponent:
umc.MessageComponent = &TextInput{}
@@ -169,8 +174,23 @@ type SelectMenuOption struct {
Default bool `json:"default"`
}
+// SelectMenuType represents select menu type.
+type SelectMenuType ComponentType
+
+// SelectMenu types.
+const (
+ StringSelectMenu = SelectMenuType(SelectMenuComponent)
+ UserSelectMenu = SelectMenuType(UserSelectMenuComponent)
+ RoleSelectMenu = SelectMenuType(RoleSelectMenuComponent)
+ MentionableSelectMenu = SelectMenuType(MentionableSelectMenuComponent)
+ ChannelSelectMenu = SelectMenuType(ChannelSelectMenuComponent)
+)
+
// SelectMenu represents select menu component.
type SelectMenu struct {
+ // Type of the select menu.
+ MenuType SelectMenuType `json:"type,omitempty"`
+ // CustomID is a developer-defined identifier for the select menu.
CustomID string `json:"custom_id,omitempty"`
// The text which will be shown in the menu if there's no default options or all options was deselected and component was closed.
Placeholder string `json:"placeholder"`
@@ -179,25 +199,31 @@ type SelectMenu struct {
// 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"`
+ 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"`
}
// Type is a method to get the type of a component.
-func (SelectMenu) Type() ComponentType {
+func (s SelectMenu) Type() ComponentType {
+ if s.MenuType != 0 {
+ return ComponentType(s.MenuType)
+ }
return SelectMenuComponent
}
// MarshalJSON is a method for marshaling SelectMenu to a JSON object.
-func (m SelectMenu) MarshalJSON() ([]byte, error) {
+func (s SelectMenu) MarshalJSON() ([]byte, error) {
type selectMenu SelectMenu
return Marshal(struct {
selectMenu
Type ComponentType `json:"type"`
}{
- selectMenu: selectMenu(m),
- Type: m.Type(),
+ selectMenu: selectMenu(s),
+ Type: s.Type(),
})
}