Skip to content

Commit

Permalink
Add ChoiceName() to choices
Browse files Browse the repository at this point in the history
  • Loading branch information
mlnrDev committed Feb 10, 2024
1 parent cdd1370 commit b4099f0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions discord/application_command_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ func (ApplicationCommandOptionFloat) Type() ApplicationCommandOptionType {
}

type ApplicationCommandOptionChoice interface {
ChoiceName() string

applicationCommandOptionChoice()
}

Expand All @@ -505,6 +507,10 @@ type ApplicationCommandOptionChoiceInt struct {
Value int `json:"value"`
}

func (c ApplicationCommandOptionChoiceInt) ChoiceName() string {
return c.Name
}

func (ApplicationCommandOptionChoiceInt) applicationCommandOptionChoice() {}

var _ ApplicationCommandOptionChoice = (*ApplicationCommandOptionChoiceString)(nil)
Expand All @@ -515,6 +521,10 @@ type ApplicationCommandOptionChoiceString struct {
Value string `json:"value"`
}

func (c ApplicationCommandOptionChoiceString) ChoiceName() string {
return c.Name
}

func (ApplicationCommandOptionChoiceString) applicationCommandOptionChoice() {}

var _ ApplicationCommandOptionChoice = (*ApplicationCommandOptionChoiceInt)(nil)
Expand All @@ -525,6 +535,10 @@ type ApplicationCommandOptionChoiceFloat struct {
Value float64 `json:"value"`
}

func (c ApplicationCommandOptionChoiceFloat) ChoiceName() string {
return c.Name
}

func (ApplicationCommandOptionChoiceFloat) applicationCommandOptionChoice() {}

type ApplicationCommandOptionAttachment struct {
Expand Down
14 changes: 14 additions & 0 deletions discord/interaction_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type AutocompleteResult struct {
func (AutocompleteResult) interactionCallbackData() {}

type AutocompleteChoice interface {
ChoiceName() string

autoCompleteChoice()
}

Expand All @@ -55,6 +57,10 @@ type AutocompleteChoiceString struct {
Value string `json:"value"`
}

func (c AutocompleteChoiceString) ChoiceName() string {
return c.Name
}

func (AutocompleteChoiceString) autoCompleteChoice() {}

type AutocompleteChoiceInt struct {
Expand All @@ -63,6 +69,10 @@ type AutocompleteChoiceInt struct {
Value int `json:"value"`
}

func (c AutocompleteChoiceInt) ChoiceName() string {
return c.Name
}

func (AutocompleteChoiceInt) autoCompleteChoice() {}

type AutocompleteChoiceFloat struct {
Expand All @@ -71,4 +81,8 @@ type AutocompleteChoiceFloat struct {
Value float64 `json:"value"`
}

func (c AutocompleteChoiceFloat) ChoiceName() string {
return c.Name
}

func (AutocompleteChoiceFloat) autoCompleteChoice() {}

0 comments on commit b4099f0

Please sign in to comment.