mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-07-30 01:11:25 +00:00
Compare commits
1 commit
e952881e17
...
f7618fb720
Author | SHA1 | Date | |
---|---|---|---|
|
f7618fb720 |
|
@ -720,8 +720,6 @@ type UserSelectComponent struct {
|
|||
ValueLimits [2]int `json:"-"`
|
||||
// Disabled disables the select if true.
|
||||
Disabled bool `json:"disabled,omitempty"`
|
||||
// SelectedUsers is the slice of UserIDs that are marked as selected by default
|
||||
SelectedUsers []UserID `json:"-"`
|
||||
}
|
||||
|
||||
// ID implements the Component interface.
|
||||
|
@ -739,17 +737,11 @@ func (s *UserSelectComponent) _icp() {}
|
|||
func (s *UserSelectComponent) MarshalJSON() ([]byte, error) {
|
||||
type sel UserSelectComponent
|
||||
|
||||
type DefaultValue struct {
|
||||
Id UserID `json:"id"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type Msg struct {
|
||||
Type ComponentType `json:"type"`
|
||||
*sel
|
||||
MinValues *int `json:"min_values,omitempty"`
|
||||
MaxValues *int `json:"max_values,omitempty"`
|
||||
DefaultValues []DefaultValue `json:"default_values,omitempty"`
|
||||
}
|
||||
|
||||
msg := Msg{
|
||||
|
@ -757,16 +749,6 @@ func (s *UserSelectComponent) MarshalJSON() ([]byte, error) {
|
|||
sel: (*sel)(s),
|
||||
}
|
||||
|
||||
var defaultValues []DefaultValue
|
||||
|
||||
if len(s.SelectedUsers) > 0 {
|
||||
for _, userId := range s.SelectedUsers {
|
||||
defaultValues = append(defaultValues, DefaultValue{Id: userId, Type: "user"})
|
||||
}
|
||||
}
|
||||
|
||||
msg.DefaultValues = defaultValues
|
||||
|
||||
if s.ValueLimits != [2]int{0, 0} {
|
||||
msg.MinValues = new(int)
|
||||
msg.MaxValues = new(int)
|
||||
|
@ -858,9 +840,8 @@ type MentionableSelectComponent struct {
|
|||
ValueLimits [2]int `json:"-"`
|
||||
// Disabled disables the select if true.
|
||||
Disabled bool `json:"disabled,omitempty"`
|
||||
// SelectedMentions is the slice of discord.UserID's and discord.RoleID's
|
||||
// that are marked as selected by default
|
||||
SelectedMentions []interface{} `json:"-"`
|
||||
// SelectedUsers is the slice of UserIDs that are marked as selected by default
|
||||
SelectedUsers []UserID `json:"-"`
|
||||
}
|
||||
|
||||
// ID implements the Component interface.
|
||||
|
@ -879,7 +860,7 @@ func (s *MentionableSelectComponent) MarshalJSON() ([]byte, error) {
|
|||
type sel MentionableSelectComponent
|
||||
|
||||
type DefaultValue struct {
|
||||
Id Snowflake `json:"id"`
|
||||
Id UserID `json:"id"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
|
@ -898,16 +879,9 @@ func (s *MentionableSelectComponent) MarshalJSON() ([]byte, error) {
|
|||
|
||||
var defaultValues []DefaultValue
|
||||
|
||||
if len(s.SelectedMentions) > 0 {
|
||||
for _, mentionId := range s.SelectedMentions {
|
||||
switch id := mentionId.(type) {
|
||||
case UserID:
|
||||
defaultValues =
|
||||
append(defaultValues, DefaultValue{Id: Snowflake(id), Type: "user"})
|
||||
case RoleID:
|
||||
defaultValues =
|
||||
append(defaultValues, DefaultValue{Id: Snowflake(id), Type: "role"})
|
||||
}
|
||||
if len(s.SelectedUsers) > 0 {
|
||||
for _, userId := range s.SelectedUsers {
|
||||
defaultValues = append(defaultValues, DefaultValue{Id: userId, Type: "user"})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue