mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-28 17:53:30 +00:00
discord: Add AttachmentOption type
This commit is contained in:
parent
09c3314cc2
commit
2c86cfe7a6
|
@ -310,6 +310,7 @@ const (
|
|||
RoleOptionType
|
||||
MentionableOptionType
|
||||
NumberOptionType
|
||||
AttachmentOptionType
|
||||
maxOptionType // for bound checking
|
||||
)
|
||||
|
||||
|
@ -328,6 +329,7 @@ const (
|
|||
// - *RoleOption
|
||||
// - *MentionableOption
|
||||
// - *NumberOption
|
||||
// - *AttachmentOption
|
||||
//
|
||||
type CommandOption interface {
|
||||
Name() string
|
||||
|
@ -430,6 +432,7 @@ func (s *SubcommandOption) UnmarshalJSON(b []byte) error {
|
|||
// - *RoleOption
|
||||
// - *MentionableOption
|
||||
// - *NumberOption
|
||||
// - *AttachmentOption
|
||||
//
|
||||
type CommandOptionValue interface {
|
||||
CommandOption
|
||||
|
@ -653,6 +656,28 @@ type NumberChoice struct {
|
|||
LocalizedName string `json:"name_localized,omitempty"`
|
||||
}
|
||||
|
||||
// AttachmentOption is a subcommand option that fits into a CommandOptionValue.
|
||||
type AttachmentOption struct {
|
||||
OptionName string `json:"name"`
|
||||
OptionNameLocalizations StringLocales `json:"name_localizations,omitempty"`
|
||||
Description string `json:"description"`
|
||||
DescriptionLocalizations StringLocales `json:"description_localizations,omitempty"`
|
||||
Required bool `json:"required"`
|
||||
// LocalizedOptionName is only populated when this is received from
|
||||
// Discord's API.
|
||||
LocalizedOptionName string `json:"name_localized,omitempty"`
|
||||
// LocalizedDescription is only populated when this is received from
|
||||
// Discord's API.
|
||||
LocalizedDescription string `json:"description_localized,omitempty"`
|
||||
}
|
||||
|
||||
// Name implements CommandOption.
|
||||
func (n *AttachmentOption) Name() string { return n.OptionName }
|
||||
|
||||
// Type implements CommandOptionValue.
|
||||
func (n *AttachmentOption) Type() CommandOptionType { return AttachmentOptionType }
|
||||
func (n *AttachmentOption) _val() {}
|
||||
|
||||
// NewCommand creates a new command.
|
||||
func NewCommand(name, description string, options ...CommandOption) Command {
|
||||
return Command{
|
||||
|
@ -873,3 +898,15 @@ func (n *NumberOption) MarshalJSON() ([]byte, error) {
|
|||
raw: (*raw)(n),
|
||||
})
|
||||
}
|
||||
|
||||
// MarshalJSON marshals AttachmentOption to JSON with the "type" field.
|
||||
func (a *AttachmentOption) MarshalJSON() ([]byte, error) {
|
||||
type raw AttachmentOption
|
||||
return json.Marshal(struct {
|
||||
Type CommandOptionType `json:"type"`
|
||||
*raw
|
||||
}{
|
||||
Type: a.Type(),
|
||||
raw: (*raw)(a),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue