component

package
v0.0.0-...-cf76b18 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: BSD-3-Clause Imports: 4 Imported by: 26

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,omitempty"`
	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 ChannelSelect

type ChannelSelect 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"`
	Required    *bool          `json:"required,omitempty"`
}

func (ChannelSelect) MarshalJSON

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

func (ChannelSelect) Type

func (i ChannelSelect) Type() ComponentType

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 BuildChannelSelect

func BuildChannelSelect(data ChannelSelect) Component

func BuildContainer

func BuildContainer(data Container) Component

func BuildFile

func BuildFile(data File) Component

func BuildInputText

func BuildInputText(data InputText) Component

func BuildLabel

func BuildLabel(data Label) Component

func BuildMediaGallery

func BuildMediaGallery(data MediaGallery) Component

func BuildMentionableSelect

func BuildMentionableSelect(data MentionableSelect) Component

func BuildRoleSelect

func BuildRoleSelect(data RoleSelect) Component

func BuildSection

func BuildSection(data Section) Component

func BuildSelectMenu

func BuildSelectMenu(data SelectMenu) Component

func BuildSeparator

func BuildSeparator(data Separator) Component

func BuildTextDisplay

func BuildTextDisplay(data TextDisplay) Component

func BuildThumbnail

func BuildThumbnail(data Thumbnail) Component

func BuildUserSelect

func BuildUserSelect(data UserSelect) 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
	ComponentUserSelect
	ComponentRoleSelect
	ComponentMentionableSelect
	ComponentChannelSelect
	ComponentSection
	ComponentTextDisplay
	ComponentThumbnail
	ComponentMediaGallery
	ComponentFile
	ComponentSeparator
	ComponentContainer ComponentType = iota + 3
	ComponentLabel
)

type Container

type Container struct {
	Components  []Component `json:"components"`
	AccentColor *int        `json:"accent_color,omitempty"`
	Spoiler     *bool       `json:"spoiler,omitempty"`
}

func (Container) MarshalJSON

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

func (Container) Type

func (i Container) Type() ComponentType

type File

type File struct {
	File    UnfurledMediaItem `json:"file"`
	Spoiler *bool             `json:"spoiler,omitempty"`
}

func (File) MarshalJSON

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

func (File) Type

func (i File) Type() ComponentType

type InputText

type InputText struct {
	Style       TextStyleTypes `json:"style"`
	CustomId    string         `json:"custom_id"`
	Label       *string        `json:"label,omitempty"`
	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 Label

type Label struct {
	Label       string    `json:"label"`
	Description *string   `json:"description,omitempty"`
	Component   Component `json:"component"` // This can only be string select or text input
}

func (Label) MarshalJSON

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

func (Label) Type

func (i Label) Type() ComponentType

type MediaGallery

type MediaGallery struct {
	Items []MediaGalleryItem `json:"items"`
}

func (MediaGallery) MarshalJSON

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

func (MediaGallery) Type

func (i MediaGallery) Type() ComponentType

type MediaGalleryItem

type MediaGalleryItem struct {
	Media       UnfurledMediaItem `json:"media,omitempty"`
	Description *string           `json:"description,omitempty"`
	Spoiler     *bool             `json:"spoiler,omitempty"`
}

type MentionableSelect

type MentionableSelect 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"`
	Required    *bool          `json:"required,omitempty"`
}

func (MentionableSelect) MarshalJSON

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

func (MentionableSelect) Type

type RoleSelect

type RoleSelect 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"`
	Required    *bool          `json:"required,omitempty"`
}

func (RoleSelect) MarshalJSON

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

func (RoleSelect) Type

func (i RoleSelect) Type() ComponentType

type Section

type Section struct {
	Components []Component `json:"components"`
	Accessory  Component   `json:"accessory,omitempty"`
}

func (Section) MarshalJSON

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

func (Section) Type

func (i Section) 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"`
	Required    *bool          `json:"required,omitempty"`
}

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 Separator

type Separator struct {
	Divider *bool `json:"divider,omitempty"`
	Spacing *int  `json:"spacing,omitempty"`
}

func (Separator) MarshalJSON

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

func (Separator) Type

func (i Separator) Type() ComponentType

type TextDisplay

type TextDisplay struct {
	Content string `json:"content"`
}

func (TextDisplay) MarshalJSON

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

func (TextDisplay) Type

func (i TextDisplay) Type() ComponentType

type TextStyleTypes

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

type Thumbnail

type Thumbnail struct {
	Media       UnfurledMediaItem `json:"media,omitempty"`
	Description *string           `json:"description,omitempty"`
	Spoiler     *bool             `json:"spoiler,omitempty"`
}

func (Thumbnail) MarshalJSON

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

func (Thumbnail) Type

func (i Thumbnail) Type() ComponentType

type UnfurledMediaItem

type UnfurledMediaItem struct {
	Url         string `json:"url"`
	ProxyUrl    string `json:"proxy_url"`
	Height      int    `json:"height"`
	Width       int    `json:"width"`
	ContentType string `json:"content_type"`
}

type UserSelect

type UserSelect struct {
	CustomId    string `json:"custom_id"`
	Placeholder string `json:"placeholder,omitempty"`
	MinValues   *int   `json:"min_values,omitempty"`
	MaxValues   *int   `json:"max_values,omitempty"`
	Disabled    bool   `json:"disabled"`
	Required    *bool  `json:"required,omitempty"`
}

func (UserSelect) MarshalJSON

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

func (UserSelect) Type

func (i UserSelect) Type() ComponentType

Jump to

Keyboard shortcuts

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