component

package
v0.0.0-...-8fd61c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2024 License: BSD-3-Clause Imports: 4 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingType  = errors.New("component was missing type field")
	ErrUnknownType  = errors.New("component had unknown type")
	ErrTypeMismatch = errors.New("data did not match component type")
)

Functions

This section is empty.

Types

type ActionRow

type ActionRow struct {
	Components []Component
}

func (ActionRow) MarshalJSON

func (a ActionRow) MarshalJSON() ([]byte, error)

func (ActionRow) Type

func (a ActionRow) Type() ComponentType

type Button

type Button struct {
	Label    string       `json:"label"`
	CustomId string       `json:"custom_id"`
	Style    ButtonStyle  `json:"style"`
	Emoji    *emoji.Emoji `json:"emoji,omitempty"`
	SkuId    *uint64      `json:"sku_id,omitempty"`
	Url      *string      `json:"url,omitempty"`
	Disabled bool         `json:"disabled"`
}

func (Button) MarshalJSON

func (b Button) MarshalJSON() ([]byte, error)

func (Button) Type

func (b Button) Type() ComponentType

type ButtonStyle

type ButtonStyle uint8
const (
	ButtonStylePrimary ButtonStyle = iota + 1
	ButtonStyleSecondary
	ButtonStyleSuccess
	ButtonStyleDanger
	ButtonStyleLink
	ButtonStylePremium
)

type Component

type Component struct {
	Type ComponentType `json:"type"`
	ComponentData
}

func BuildActionRow

func BuildActionRow(components ...Component) Component

func BuildButton

func BuildButton(data Button) Component

func BuildInputText

func BuildInputText(data InputText) Component

func BuildSelectMenu

func BuildSelectMenu(data SelectMenu) Component

func (Component) MarshalJSON

func (c Component) MarshalJSON() ([]byte, error)

func (*Component) UnmarshalJSON

func (c *Component) UnmarshalJSON(data []byte) error

type ComponentData

type ComponentData interface {
	Type() ComponentType
}

type ComponentType

type ComponentType uint8
const (
	ComponentActionRow ComponentType = iota + 1
	ComponentButton
	ComponentSelectMenu
	ComponentInputText
)

type InputText

type InputText struct {
	Style       TextStyleTypes `json:"style"`
	CustomId    string         `json:"custom_id"`
	Label       string         `json:"label"`
	Placeholder *string        `json:"placeholder,omitempty"`
	MinLength   *uint32        `json:"min_length,omitempty"`
	MaxLength   *uint32        `json:"max_length,omitempty"`
	Required    *bool          `json:"required,omitempty"`
	Value       *string        `json:"value,omitempty"`
}

func (InputText) MarshalJSON

func (i InputText) MarshalJSON() ([]byte, error)

func (InputText) Type

func (i InputText) Type() ComponentType

type SelectMenu

type SelectMenu struct {
	CustomId    string         `json:"custom_id"`
	Options     []SelectOption `json:"options"`
	Placeholder string         `json:"placeholder,omitempty"`
	MinValues   *int           `json:"min_values,omitempty"`
	MaxValues   *int           `json:"max_values,omitempty"`
	Disabled    bool           `json:"disabled"`
}

func (SelectMenu) MarshalJSON

func (s SelectMenu) MarshalJSON() ([]byte, error)

func (SelectMenu) Type

func (s SelectMenu) Type() ComponentType

type SelectOption

type SelectOption struct {
	Label       string       `json:"label"`
	Value       string       `json:"value"`
	Description string       `json:"description,omitempty"`
	Emoji       *emoji.Emoji `json:"emoji,omitempty"`
	Default     bool         `json:"default"`
}

type TextStyleTypes

type TextStyleTypes uint8
const (
	TextStyleShort TextStyleTypes = iota + 1
	TextStyleParagraph
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL