Documentation ¶
Index ¶
- Constants
- Variables
- type ActionsRow
- type Attachment
- type Button
- type ButtonStyle
- type ClientStatus
- type ComponentEmoji
- type ComponentType
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedProvider
- type Emoji
- type Guild
- type MessageComponent
- type MessageData
- type MessageEmbedImage
- type MessageEmbedThumbnail
- type MessageEventData
- type MessageInteraction
- type MessageReference
- type ModalData
- type OnlineStatus
- type Reaction
- type ReadyEventData
- type SelectMenu
- type SelectMenuDefaultValue
- type SelectMenuDefaultValueType
- type SelectMenuOption
- type SelectMenuType
- type TextInput
- type TextInputStyle
- type User
Constants ¶
const ( StringSelectMenu = SelectMenuType(SelectMenuComponent) UserSelectMenu = SelectMenuType(UserSelectMenuComponent) RoleSelectMenu = SelectMenuType(RoleSelectMenuComponent) MentionableSelectMenu = SelectMenuType(MentionableSelectMenuComponent) ChannelSelectMenu = SelectMenuType(ChannelSelectMenuComponent) )
SelectMenu types.
Variables ¶
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 ¶
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"` Thumbnail *MessageEmbedThumbnail `json:"thumbnail,omitempty"` Provider EmbedProvider `json:"provider,omitempty"` Author EmbedAuthor `json:"author,omitempty"` Fields []EmbedField `json:"fields,omitempty"` }
type EmbedAuthor ¶
type EmbedField ¶
type EmbedFooter ¶
type EmbedFooter struct {}
type EmbedProvider ¶
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 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 MessageEmbedThumbnail ¶
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 MessageReference ¶
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 ¶
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 ReadyEventData ¶
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 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 ¶
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"` }