types

package
v1.6.0-pre1.0...-9505211 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

SelectMenu types.

Variables

View Source
var (
	ErrGatewayAlreadyConnected = errors.New("gateway is already connected")
	ErrGatewayNotConnected     = errors.New("gateway is not connected")
)

Functions

This section is empty.

Types

type ActionsRow

type ActionsRow struct {
	Components []MessageComponent `json:"components"`
}

ActionsRow is a container for components within one row.

func (ActionsRow) MarshalJSON

func (r ActionsRow) MarshalJSON() ([]byte, error)

MarshalJSON is a method for marshaling ActionsRow to a JSON object.

func (ActionsRow) Type

func (r ActionsRow) Type() ComponentType

Type is a method to get the type of a component.

func (*ActionsRow) UnmarshalJSON

func (r *ActionsRow) UnmarshalJSON(data []byte) error

UnmarshalJSON is a helper function to unmarshal Actions Row.

type Attachment

type Attachment struct {
	ID                 string `json:"id"`
	Filename           string `json:"filename"`
	Size               int    `json:"size"`
	URL                string `json:"url"`
	ProxyURL           string `json:"proxy_url"`
	Width              int    `json:"width"`
	Height             int    `json:"height"`
	ContentType        string `json:"content_type"`
	Placeholder        string `json:"placeholder"`
	PlaceholderVersion int    `json:"placeholder_version"`
}

type Button

type Button struct {
	Label    string         `json:"label"`
	Style    ButtonStyle    `json:"style"`
	Disabled bool           `json:"disabled"`
	Emoji    ComponentEmoji `json:"emoji"`

	// NOTE: Only button with LinkButton style can have link. Also, URL is mutually exclusive with CustomID.
	URL      string `json:"url,omitempty"`
	CustomID string `json:"custom_id,omitempty"`
}

Button represents button component.

func (Button) MarshalJSON

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

MarshalJSON is a method for marshaling Button to a JSON object.

func (Button) Type

func (Button) Type() ComponentType

Type is a method to get the type of a component.

type ButtonStyle

type ButtonStyle uint

ButtonStyle is style of button.

const (
	// PrimaryButton is a button with blurple color.
	PrimaryButton ButtonStyle = 1
	// SecondaryButton is a button with grey color.
	SecondaryButton ButtonStyle = 2
	// SuccessButton is a button with green color.
	SuccessButton ButtonStyle = 3
	// DangerButton is a button with red color.
	DangerButton ButtonStyle = 4
	// LinkButton is a special type of button which navigates to a URL. Has grey color.
	LinkButton ButtonStyle = 5
)

Button styles.

type ClientStatus

type ClientStatus struct {
	Desktop OnlineStatus `json:"desktop,omitempty"`
	Mobile  OnlineStatus `json:"mobile,omitempty"`
	Web     OnlineStatus `json:"web,omitempty"`
}

ClientStatus (https://discord.com/developers/docs/topics/gateway#client-status-object)

type ComponentEmoji

type ComponentEmoji struct {
	Name     string `json:"name,omitempty"`
	ID       string `json:"id,omitempty"`
	Animated bool   `json:"animated,omitempty"`
}

ComponentEmoji represents button emoji, if it does have one.

type ComponentType

type ComponentType uint

ComponentType is type of component.

const (
	ActionsRowComponent            ComponentType = 1
	ButtonComponent                ComponentType = 2
	SelectMenuComponent            ComponentType = 3
	TextInputComponent             ComponentType = 4
	UserSelectMenuComponent        ComponentType = 5
	RoleSelectMenuComponent        ComponentType = 6
	MentionableSelectMenuComponent ComponentType = 7
	ChannelSelectMenuComponent     ComponentType = 8
)

MessageComponent types.

type Embed

type Embed struct {
	Title       string                 `json:"title,omitempty"`
	Type        string                 `json:"type,omitempty"`
	Description string                 `json:"description,omitempty"`
	Timestamp   *string                `json:"timestamp,omitempty"`
	URL         string                 `json:"url,omitempty"`
	Image       *MessageEmbedImage     `json:"image,omitempty"`
	Color       int                    `json:"color,omitempty"`
	Footer      EmbedFooter            `json:"footer,omitempty"`
	Thumbnail   *MessageEmbedThumbnail `json:"thumbnail,omitempty"`
	Provider    EmbedProvider          `json:"provider,omitempty"`
	Author      EmbedAuthor            `json:"author,omitempty"`
	Fields      []EmbedField           `json:"fields,omitempty"`
}

type EmbedAuthor

type EmbedAuthor struct {
	Name    string `json:"name,omitempty"`
	URL     string `json:"url,omitempty"`
	IconURL string `json:"icon_url,omitempty"`

	ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

type EmbedField

type EmbedField struct {
	Name   string `json:"name,omitempty"`
	Value  string `json:"value,omitempty"`
	Inline bool   `json:"inline,omitempty"`
}

type EmbedFooter

type EmbedFooter struct {
	Text         string `json:"text,omitempty"`
	IconURL      string `json:"icon_url,omitempty"`
	ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}

type EmbedProvider

type EmbedProvider struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}

type Emoji

type Emoji struct {
	ID            string   `json:"id"`
	Name          string   `json:"name,omitempty"`
	Roles         []string `json:"roles,omitempty"`
	User          User     `json:"user,omitempty"`
	RequireColons bool     `json:"require_colons,omitempty"`
	Managed       bool     `json:"managed,omitempty"`
	Animated      bool     `json:"animated,omitempty"`
	Available     bool     `json:"available,omitempty"`
}

type Guild

type Guild struct {
	ID   string `json:"id"`
	Name string `json:"name"`

	Unavailable bool `json:"unavailable,omitempty"`
}

type MessageComponent

type MessageComponent interface {
	json.Marshaler
	Type() ComponentType
}

MessageComponent is a base interface for all message components.

func MessageComponentFromJSON

func MessageComponentFromJSON(b []byte) (MessageComponent, error)

MessageComponentFromJSON is a helper function for unmarshaling message components

type MessageData

type MessageData struct {
	Type             int                `json:"type,omitempty"`
	Content          string             `json:"content,omitempty"`
	ChannelID        string             `json:"channel_id,omitempty"`
	Embeds           []Embed            `json:"embeds,omitempty"`
	Reactions        []Reaction         `json:"reactions,omitempty"`
	Author           User               `json:"author,omitempty"`
	GuildID          string             `json:"guild_id,omitempty"`
	MessageID        string             `json:"id,omitempty"`
	Components       []MessageComponent `json:"-"`
	Attachments      []Attachment       `json:"attachments,omitempty"`
	Flags            int                `json:"flags,omitempty"`
	MessageReference MessageReference   `json:"message_reference,omitempty"`
	Interaction      MessageInteraction `json:"interaction,omitempty"`
	RawComponents    json.RawMessage    `json:"components,omitempty"`
	Timestamp        time.Time          `json:"timestamp"`
}

func (*MessageData) UnmarshalJSON

func (md *MessageData) UnmarshalJSON(b []byte) error

type MessageEmbedImage

type MessageEmbedImage struct {
	URL      string `json:"url,omitempty"`
	ProxyURL string `json:"proxy_url,omitempty"`
	Width    int    `json:"width,omitempty"`
	Height   int    `json:"height,omitempty"`
}

type MessageEmbedThumbnail

type MessageEmbedThumbnail struct {
	URL      string `json:"url,omitempty"`
	ProxyURL string `json:"proxy_url,omitempty"`
	Width    int    `json:"width,omitempty"`
	Height   int    `json:"height,omitempty"`
}

type MessageEventData

type MessageEventData struct {
	// Data is in different struct because it needs to be recursive
	MessageData
	ReferencedMessage MessageData `json:"referenced_message"`
}

type MessageInteraction

type MessageInteraction struct {
	ID   string `json:"id,omitempty"`
	Type int    `json:"type,omitempty"`
	Name string `json:"name,omitempty"`
	User User   `json:"user,omitempty"`
}

type MessageReference

type MessageReference struct {
	ChannelID string `json:"channel_id"`
	MessageID string `json:"message_id"`
	GuildID   string `json:"guild_id"`
}

type ModalData

type ModalData struct {
	Components    []MessageComponent `json:"-"`
	CustomID      string             `json:"custom_id"`
	Title         string             `json:"title"`
	ID            string             `json:"id"`
	ChannelID     string             `json:"channel_id"`
	RawComponents json.RawMessage    `json:"components,omitempty"`
}

func (*ModalData) UnmarshalJSON

func (md *ModalData) UnmarshalJSON(b []byte) error

type OnlineStatus

type OnlineStatus string

OnlineStatus (https://discord.com/developers/docs/topics/gateway#update-presence-status-types)

const (
	OnlineStatusOnline    OnlineStatus = "online"
	OnlineStatusDND       OnlineStatus = "dnd"
	OnlineStatusIdle      OnlineStatus = "idle"
	OnlineStatusInvisible OnlineStatus = "invisible"
	OnlineStatusOffline   OnlineStatus = "offline"
)

type Reaction

type Reaction struct {
	Emojis Emoji `json:"emoji,omitempty"`
	Count  int   `json:"count,omitempty"`
}

type ReadyEventData

type ReadyEventData struct {
	Version          int     `json:"v"`
	User             User    `json:"user"`
	Guilds           []Guild `json:"guilds"`
	SessionID        string  `json:"session_id"`
	ResumeGatewayURL string  `json:"resume_gateway_url"`
}

type SelectMenu

type SelectMenu struct {
	// Type of the select menu.
	MenuType SelectMenuType `json:"type,omitempty"`
	// CustomID is a developer-defined identifier for the select menu.
	CustomID string `json:"custom_id,omitempty"`
	// The text which will be shown in the menu if there's no default options or all options was deselected and component was closed.
	Placeholder string `json:"placeholder"`
	// This value determines the minimal amount of selected items in the menu.
	MinValues *int `json:"min_values,omitempty"`
	// This value determines the maximal amount of selected items in the menu.
	// If MaxValues or MinValues are greater than one then the user can select multiple items in the component.
	MaxValues int `json:"max_values,omitempty"`
	// List of default values for auto-populated select menus.
	// NOTE: Number of entries should be in the range defined by MinValues and MaxValues.
	DefaultValues []SelectMenuDefaultValue `json:"default_values,omitempty"`

	Options  []SelectMenuOption `json:"options,omitempty"`
	Disabled bool               `json:"disabled"`
}

SelectMenu represents select menu component.

func (SelectMenu) MarshalJSON

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

MarshalJSON is a method for marshaling SelectMenu to a JSON object.

func (SelectMenu) Type

func (s SelectMenu) Type() ComponentType

Type is a method to get the type of a component.

type SelectMenuDefaultValue

type SelectMenuDefaultValue struct {
	// ID of the entity.
	ID string `json:"id"`
	// Type of the entity.
	Type SelectMenuDefaultValueType `json:"type"`
}

SelectMenuDefaultValue represents an entity selected by default in auto-populated select menus.

type SelectMenuDefaultValueType

type SelectMenuDefaultValueType string

SelectMenuDefaultValueType represents the type of an entity selected by default in auto-populated select menus.

const (
	SelectMenuDefaultValueUser    SelectMenuDefaultValueType = "user"
	SelectMenuDefaultValueRole    SelectMenuDefaultValueType = "role"
	SelectMenuDefaultValueChannel SelectMenuDefaultValueType = "channel"
)

SelectMenuDefaultValue types.

type SelectMenuOption

type SelectMenuOption struct {
	Label       string         `json:"label,omitempty"`
	Value       string         `json:"value"`
	Description string         `json:"description"`
	Emoji       ComponentEmoji `json:"emoji"`
	// Determines whenever option is selected by default or not.
	Default bool `json:"default"`
}

SelectMenuOption represents an option for a select menu.

type SelectMenuType

type SelectMenuType ComponentType

SelectMenuType represents select menu type.

type TextInput

type TextInput struct {
	CustomID    string         `json:"custom_id"`
	Label       string         `json:"label"`
	Style       TextInputStyle `json:"style"`
	Placeholder string         `json:"placeholder,omitempty"`
	Value       string         `json:"value,omitempty"`
	Required    bool           `json:"required"`
	MinLength   int            `json:"min_length,omitempty"`
	MaxLength   int            `json:"max_length,omitempty"`
}

TextInput represents text input component.

func (TextInput) MarshalJSON

func (m TextInput) MarshalJSON() ([]byte, error)

MarshalJSON is a method for marshaling TextInput to a JSON object.

func (TextInput) Type

func (TextInput) Type() ComponentType

Type is a method to get the type of a component.

type TextInputStyle

type TextInputStyle uint

TextInputStyle is style of text in TextInput component.

const (
	TextInputShort     TextInputStyle = 1
	TextInputParagraph TextInputStyle = 2
)

Text styles

type User

type User struct {
	ID            string       `json:"id"`
	Username      string       `json:"username"`
	Discriminator string       `json:"discriminator"`
	Avatar        string       `json:"avatar"`
	Bot           bool         `json:"bot,omitempty"`
	System        bool         `json:"system,omitempty"`
	MFAEnabled    bool         `json:"mfa_enabled,omitempty"`
	Locale        string       `json:"locale,omitempty"`
	Verified      bool         `json:"verified,omitempty"`
	Email         string       `json:"email,omitempty"`
	Status        OnlineStatus `json:"status,omitempty"`
}

Jump to

Keyboard shortcuts

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