Documentation
¶
Index ¶
- Constants
- type AllowedMentions
- type Attachment
- type ButtonStyle
- type ChannelMention
- type ChannelType
- type Choice
- type Client
- func (client *Client) AwaitComponent(customIDs []string, timeout time.Duration) (<-chan *ComponentInteraction, func(), error)
- func (client *Client) AwaitModal(customID string, timeout time.Duration) (<-chan *ModalInteraction, func(), error)
- func (client *Client) CrosspostMessage(channelID Snowflake, messageID Snowflake) error
- func (client *Client) DeleteMessage(channelID Snowflake, messageID Snowflake) error
- func (client *Client) EditMessage(channelID Snowflake, messageID Snowflake, content Message) error
- func (client *Client) FetchMember(guildID Snowflake, memberID Snowflake) (Member, error)
- func (client *Client) FetchUser(id Snowflake) (User, error)
- func (client *Client) HandleDiscordRequest(w http.ResponseWriter, r *http.Request)
- func (client *Client) Ping() time.Duration
- func (client *Client) RegisterCommand(command Command) error
- func (client *Client) RegisterComponent(customIDs []string, fn func(ComponentInteraction)) error
- func (client *Client) RegisterModal(customID string, fn func(ModalInteraction)) error
- func (client *Client) RegisterSubCommand(subCommand Command, rootCommandName string) error
- func (client *Client) SendLinearMessage(channelID Snowflake, content string) (Message, error)
- func (client *Client) SendMessage(channelID Snowflake, message Message, files []*os.File) (Message, error)
- func (client *Client) SendPrivateMessage(userID Snowflake, content Message, files []*os.File) (Message, error)
- func (client *Client) SyncCommands(guildIDs []Snowflake, whitelist []string, switchMode bool) error
- type ClientOptions
- type Command
- type CommandInteraction
- func (itx CommandInteraction) Defer(ephemeral bool) error
- func (itx CommandInteraction) DeleteFollowUp(messageID Snowflake, content ResponseMessage) error
- func (itx CommandInteraction) DeleteReply() error
- func (itx CommandInteraction) EditFollowUp(messageID Snowflake, content ResponseMessage) error
- func (itx CommandInteraction) EditReply(content ResponseMessageData, ephemeral bool) error
- func (itx CommandInteraction) GetFocusedValue() (string, any)
- func (itx CommandInteraction) GetOptionValue(name string) (any, bool)
- func (itx CommandInteraction) ResolveAttachment(id Snowflake) *Attachment
- func (itx CommandInteraction) ResolveChannel(id Snowflake) *PartialChannel
- func (itx CommandInteraction) ResolveMember(id Snowflake) *Member
- func (itx CommandInteraction) ResolveMessage(id Snowflake) *Message
- func (itx CommandInteraction) ResolveRole(id Snowflake) *Role
- func (itx CommandInteraction) ResolveUser(id Snowflake) *User
- func (itx CommandInteraction) SendFollowUp(content ResponseMessageData, ephemeral bool) (Message, error)
- func (itx CommandInteraction) SendLinearReply(content string, ephemeral bool) error
- func (itx CommandInteraction) SendModal(modal ResponseModalData) error
- func (itx CommandInteraction) SendReply(reply ResponseMessageData, ephemeral bool, files []*os.File) error
- type CommandInteractionData
- type CommandInteractionOption
- type CommandOption
- type CommandType
- type Component
- type ComponentInteraction
- func (itx ComponentInteraction) Acknowledge() error
- func (itx ComponentInteraction) AcknowledgeWithLinearMessage(content string, ephemeral bool) error
- func (itx ComponentInteraction) AcknowledgeWithMessage(content ResponseMessageData, ephemeral bool) error
- func (itx ComponentInteraction) AcknowledgeWithModal(modal ResponseModalData) error
- type ComponentInteractionData
- type ComponentRow
- type ComponentType
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedImage
- type EmbedProvider
- type EmbedThumbnail
- type EmbedVideo
- type Emoji
- type InteractionDataResolved
- type InteractionType
- type InteractionTypeExtractor
- type Language
- type Member
- type Message
- type MessageInteraction
- type MessageReference
- type ModalInteraction
- func (itx ModalInteraction) Acknowledge() error
- func (itx ModalInteraction) AcknowledgeWithLinearMessage(content string, ephemeral bool) error
- func (itx ModalInteraction) AcknowledgeWithMessage(response ResponseMessageData, ephemeral bool) error
- func (itx ModalInteraction) AcknowledgeWithModal(modal ResponseModalData) error
- func (itx ModalInteraction) GetInputValue(customID string) string
- type ModalInteractionData
- type NitroType
- type OptionType
- type PartialChannel
- type PartialEmoji
- type Reaction
- type ResponseAutoComplete
- type ResponseAutoCompleteData
- type ResponseMessage
- type ResponseMessageData
- type ResponseModal
- type ResponseModalData
- type ResponseType
- type RestClient
- type Role
- type RoleTag
- type SelectMenuOption
- type Snowflake
- type StickerFormatType
- type StickerItem
- type TextInputStyle
- type User
Constants ¶
const ( DISCORD_API_URL = "https://discord.com/api/v10" DISCORD_CDN_URL = "https://cdn.discordapp.com" DISCORD_EPOCH = 1420070400000 // Discord epoch in milliseconds USER_AGENT = "DiscordApp https://github.com/Amatsagu/tempest" CONTENT_TYPE_JSON = "application/json" ROOT_PLACEHOLDER = "-" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllowedMentions ¶
type Attachment ¶
type Attachment struct { ID Snowflake `json:"id"` FileName string `json:"filename"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` ContentType string `json:"content_type,omitempty"` Size uint64 `json:"size"` URL string `json:"url"` ProxyURL string `json:"proxy_url"` Height uint `json:"height,omitempty"` Width uint `json:"width,omitempty"` Ephemeral bool `json:"ephemeral,omitempty"` DurationSecs float64 `json:"duration_secs,omitempty"` Waveform string `json:"waveform,omitempty"` Flags uint64 `json:"flags,omitempty"` }
https://discord.com/developers/docs/resources/channel#attachment-object
type ButtonStyle ¶
type ButtonStyle uint8
https://discord.com/developers/docs/interactions/message-components#button-object-button-styles
const ( PRIMARY_BUTTON_STYLE ButtonStyle = iota + 1 // blurple SECONDARY_BUTTON_STYLE // grey SUCCESS_BUTTON_STYLE // green DANGER_BUTTON_STYLE // red LINK_BUTTON_STYLE // grey, navigate to URL )
type ChannelMention ¶
type ChannelMention struct { ID Snowflake `json:"id"` Name string `json:"name"` GuildID Snowflake `json:"guild_id"` Type ChannelType `json:"type"` }
type ChannelType ¶
type ChannelType uint8
https://discord.com/developers/docs/resources/channel#channel-object-channel-types
const ( GUILD_TEXT_CHANNEL_TYPE ChannelType = iota DM_CHANNEL_TYPE GUILD_VOICE_CHANNEL_TYPE GROUP_DM_CHANNEL_TYPE GUILD_CATEGORY_CHANNEL_TYPE GUILD_ANNOUNCEMENT_CHANNEL_TYPE // Formerly news channel. GUILD_ANNOUNCEMENT_THREAD_CHANNEL_TYPE GUILD_PUBLIC_THREAD_CHANNEL_TYPE GUILD_PRIVATE_THREAD_CHANNEL_TYPE GUILD_STAGE_VOICE_CHANNEL_TYPE GUILD_DIRECTORY_CHANNEL_TYPE GUILD_FORUM_CHANNEL_TYPE )
func (ChannelType) MarshalJSON ¶
func (ct ChannelType) MarshalJSON() (p []byte, err error)
type Choice ¶
type Choice struct { Name string `json:"name"` NameLocalizations map[string]string `json:"name_localizations,omitempty"` // https://discord.com/developers/docs/reference#locales Value any `json:"value"` // string, float64 (double or integer) or bool }
type Client ¶
type Client struct { Rest *RestClient ApplicationID Snowflake PublicKey ed25519.PublicKey // contains filtered or unexported fields }
func NewClient ¶
func NewClient(options ClientOptions) *Client
func (*Client) AwaitComponent ¶
func (client *Client) AwaitComponent(customIDs []string, timeout time.Duration) (<-chan *ComponentInteraction, func(), error)
Makes client dynamically "listen" incoming component type interactions. When component custom id matches - it'll send back interaction through channel. On timeout (min 2s -> max 15min) - client will send <nil> through channel and automatically call close function.
Warning! Components handled this way will already be acknowledged.
func (*Client) AwaitModal ¶
func (client *Client) AwaitModal(customID string, timeout time.Duration) (<-chan *ModalInteraction, func(), error)
Makes client dynamically "listen" incoming modal type interactions. When modal custom id matches - it'll send back interaction through channel. On timeout (min 30s -> max 15min) - client will send <nil> through channel and automatically call close function.
Warning! Components handled this way will already be acknowledged.
func (*Client) CrosspostMessage ¶
func (*Client) DeleteMessage ¶
func (*Client) EditMessage ¶
func (*Client) FetchMember ¶
func (*Client) HandleDiscordRequest ¶
func (client *Client) HandleDiscordRequest(w http.ResponseWriter, r *http.Request)
func (*Client) RegisterCommand ¶
func (*Client) RegisterComponent ¶
func (client *Client) RegisterComponent(customIDs []string, fn func(ComponentInteraction)) error
Bind function to all components with matching custom ids. App will automatically run bound function whenever receiving component interaction with matching custom id.
func (*Client) RegisterModal ¶
func (client *Client) RegisterModal(customID string, fn func(ModalInteraction)) error
Bind function to modal with matching custom id. App will automatically run bound function whenever receiving modal interaction with matching custom id.
func (*Client) RegisterSubCommand ¶
func (*Client) SendLinearMessage ¶
func (*Client) SendMessage ¶
func (*Client) SendPrivateMessage ¶
func (client *Client) SendPrivateMessage(userID Snowflake, content Message, files []*os.File) (Message, error)
Creates (or fetches if already exists) user's private text channel (DM) and tries to send message into it. Warning! Discord's user channels endpoint has huge rate limits so please reuse Message#ChannelID whenever possible.
func (*Client) SyncCommands ¶
Sync currently cached slash commands to discord API. By default it'll try to make (bulk) global update (limit 100 updates per day), provide array with guild id snowflakes to update data only for specific guilds. You can also add second param -> slice with all command names you want to update (whitelist). There's also third, boolean param that when = true will reverse wishlist to work as blacklist.
type ClientOptions ¶
type ClientOptions struct { PublicKey string // Hash like key used to verify incoming payloads from Discord. (default: <nil>) Rest *RestClient PreCommandHook func(cmd *Command, itx *CommandInteraction) bool // Function that runs before each command. Return type signals whether to continue command execution (return with false to stop early). PostCommandHook func(cmd *Command, itx *CommandInteraction) // Function that runs after each command. ComponentHandler func(itx *ComponentInteraction) // Function that runs for each unhandled component. ModalHandler func(itx *ModalInteraction) // Function that runs for each unhandled modal. }
type Command ¶
type Command struct { ID Snowflake `json:"-"` // Omit in json parsing for now because it was breaking Client#commandParse. Type CommandType `json:"type,omitempty"` ApplicationID Snowflake `json:"application_id"` GuildID Snowflake `json:"guild_id,omitempty"` Name string `json:"name"` NameLocalizations map[Language]string `json:"name_localizations,omitempty"` // https://discord.com/developers/docs/reference#locales Description string `json:"description"` DescriptionLocalizations map[Language]string `json:"description_localizations,omitempty"` Options []CommandOption `json:"options,omitempty"` DefaultMemberPermissions uint64 `json:"default_member_permissions,string,omitempty"` // Set of permissions represented as a bit set. Set it to 0 to make command unavailable for regular members. AvailableInDM bool `json:"dm_permission,omitempty"` // Whether command should be visible (usable) from private, dm channels. Works only for global commands! NSFW bool `json:"nsfw,omitempty"` // https://discord.com/developers/docs/interactions/application-commands#agerestricted-commands Version Snowflake `json:"version,omitempty"` // Autoincrementing version identifier updated during substantial record changes AutoCompleteHandler func(itx CommandInteraction) []Choice `json:"-"` // Custom handler for auto complete interactions. It's a Tempest specific field. SlashCommandHandler func(itx *CommandInteraction) `json:"-"` // Custom handler for slash command interactions. It's a Tempest specific field. It receives pointer to CommandInteraction as it's being used with pre & post client hooks. }
type CommandInteraction ¶
type CommandInteraction struct { ID Snowflake `json:"id"` ApplicationID Snowflake `json:"application_id"` Type InteractionType `json:"type"` Data CommandInteractionData `json:"data"` GuildID Snowflake `json:"guild_id,omitempty"` ChannelID Snowflake `json:"channel_id,omitempty"` Member *Member `json:"member,omitempty"` User *User `json:"user,omitempty"` Token string `json:"token"` // Temporary token used for responding to the interaction. It's not the same as bot/app token. Version uint8 `json:"version"` // Read-only property, always = 1. PermissionFlags uint64 `json:"app_permissions,string"` // Bitwise set of permissions the app or bot has within the channel the interaction was sent from. Locale string `json:"locale,omitempty"` // Selected language of the invoking user. GuildLocale string `json:"guild_locale,omitempty"` // Guild's preferred locale, available if invoked in a guild. Client *Client `json:"-"` }
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
func (CommandInteraction) Defer ¶
func (itx CommandInteraction) Defer(ephemeral bool) error
Use to let user/member know that bot is processing command. Make ephemeral = true to make notification visible only to target.
func (CommandInteraction) DeleteFollowUp ¶
func (itx CommandInteraction) DeleteFollowUp(messageID Snowflake, content ResponseMessage) error
func (CommandInteraction) DeleteReply ¶
func (itx CommandInteraction) DeleteReply() error
func (CommandInteraction) EditFollowUp ¶
func (itx CommandInteraction) EditFollowUp(messageID Snowflake, content ResponseMessage) error
func (CommandInteraction) EditReply ¶
func (itx CommandInteraction) EditReply(content ResponseMessageData, ephemeral bool) error
func (CommandInteraction) GetFocusedValue ¶
func (itx CommandInteraction) GetFocusedValue() (string, any)
Warning! This method is only for handling auto complete interaction which is a part of command logic. Returns option name and its value of triggered option. Option name is always of string type but you'll need to check type of value.
func (CommandInteraction) GetOptionValue ¶
func (itx CommandInteraction) GetOptionValue(name string) (any, bool)
Returns value of any type. Check second value to check whether option was provided or not (true if yes).
func (CommandInteraction) ResolveAttachment ¶
func (itx CommandInteraction) ResolveAttachment(id Snowflake) *Attachment
Returns pointer to attachment if present in interaction.data.resolved. It'll return <nil> if there's no resolved attachment.
func (CommandInteraction) ResolveChannel ¶
func (itx CommandInteraction) ResolveChannel(id Snowflake) *PartialChannel
Returns pointer to partial channel if present in interaction.data.resolved. It'll return <nil> if there's no resolved partial channel.
func (CommandInteraction) ResolveMember ¶
func (itx CommandInteraction) ResolveMember(id Snowflake) *Member
Returns pointer to member if present in interaction.data.resolved and binds member.user. It'll return <nil> if there's no resolved member.
func (CommandInteraction) ResolveMessage ¶
func (itx CommandInteraction) ResolveMessage(id Snowflake) *Message
Returns pointer to message if present in interaction.data.resolved. It'll return <nil> if there's no resolved message.
func (CommandInteraction) ResolveRole ¶
func (itx CommandInteraction) ResolveRole(id Snowflake) *Role
Returns pointer to guild role if present in interaction.data.resolved. It'll return <nil> if there's no resolved role.
func (CommandInteraction) ResolveUser ¶
func (itx CommandInteraction) ResolveUser(id Snowflake) *User
Returns pointer to user if present in interaction.data.resolved. It'll return <nil> if there's no resolved user.
func (CommandInteraction) SendFollowUp ¶
func (itx CommandInteraction) SendFollowUp(content ResponseMessageData, ephemeral bool) (Message, error)
func (CommandInteraction) SendLinearReply ¶
func (itx CommandInteraction) SendLinearReply(content string, ephemeral bool) error
Use that for simple text messages that won't be modified.
func (CommandInteraction) SendModal ¶
func (itx CommandInteraction) SendModal(modal ResponseModalData) error
func (CommandInteraction) SendReply ¶
func (itx CommandInteraction) SendReply(reply ResponseMessageData, ephemeral bool, files []*os.File) error
Acknowledges the interaction with a message. Set ephemeral = true to make message visible only to target.
type CommandInteractionData ¶
type CommandInteractionData struct { ID Snowflake `json:"id,omitempty"` Name string `json:"name"` Type CommandType `json:"type"` Resolved *InteractionDataResolved `json:"resolved,omitempty"` Options []*CommandInteractionOption `json:"options,omitempty"` GuildID Snowflake `json:"guild_id,omitempty"` TargetID Snowflake `json:"target_id,omitempty"` // ID of either user or message targeted. Depends whether it was user command or message command. }
type CommandInteractionOption ¶
type CommandInteractionOption struct { Name string `json:"name"` Type OptionType `json:"type"` Value any `json:"value,omitempty"` // string, float64 (double or integer) or bool Options []*CommandInteractionOption `json:"options,omitempty"` Focused bool `json:"focused,omitempty"` }
type CommandOption ¶
type CommandOption struct { Type OptionType `json:"type"` Name string `json:"name"` NameLocalizations map[Language]string `json:"name_localizations,omitempty"` // https://discord.com/developers/docs/reference#locales Description string `json:"description"` DescriptionLocalizations map[Language]string `json:"description_localizations,omitempty"` Required bool `json:"required,omitempty"` MinValue float64 `json:"min_value,omitempty"` MaxValue float64 `json:"max_value,omitempty"` MinLength uint `json:"min_length,omitempty"` MaxLength uint `json:"max_length,omitempty"` Options []CommandOption `json:"options,omitempty"` ChannelTypes []ChannelType `json:"channel_types,omitempty"` Choices []Choice `json:"choices,omitempty"` AutoComplete bool `json:"autocomplete,omitempty"` // Required to be = true if you want to catch it later in auto complete handler. }
type CommandType ¶
type CommandType uint8
const ( CHAT_INPUT_COMMAND_TYPE CommandType = iota + 1 // Default option, a slash command. USER_COMMAND_TYPE // Mounted to user/member profile. MESSAGE_COMMAND_TYPE // Mounted to text message. )
type Component ¶
type Component struct { Type ComponentType `json:"type"` CustomID string `json:"custom_id,omitempty"` Style uint8 `json:"style,omitempty"` // Either ButtonStyle or TextInputStyle. Label string `json:"label,omitempty"` Emoji *PartialEmoji `json:"emoji,omitempty"` URL string `json:"url,omitempty"` Disabled bool `json:"disabled,omitempty"` Placeholder string `json:"placeholder,omitempty"` MinValues uint64 `json:"min_values,omitempty"` MaxValues uint64 `json:"max_values,omitempty"` Required bool `json:"required,omitempty"` Options []*SelectMenuOption `json:"options,omitempty"` Value string `json:"value,omitempty"` // Contains menu choice or text input value from user modal submit. ChannelTypes []*ChannelType `json:"channel_types,omitempty"` // Only available for 8th ComponentType. MinLength uint64 `json:"min_length,omitempty"` // Only available for text input components MaxLength uint64 `json:"max_length,omitempty"` // Only available for text input components }
Generic Component super struct (because Go doesn't support unions)!
https://discord.com/developers/docs/interactions/message-components#button-object-button-structure
https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-structure
type ComponentInteraction ¶
type ComponentInteraction struct { ID Snowflake `json:"id"` ApplicationID Snowflake `json:"application_id"` Type InteractionType `json:"type"` Data ComponentInteractionData `json:"data"` GuildID Snowflake `json:"guild_id,omitempty"` ChannelID Snowflake `json:"channel_id,omitempty"` Member *Member `json:"member,omitempty"` User *User `json:"user,omitempty"` Token string `json:"token"` // Temporary token used for responding to the interaction. It's not the same as bot/app token. Version uint8 `json:"version"` // Read-only property, always = 1. Message Message `json:"message"` PermissionFlags uint64 `json:"app_permissions,string"` // Bitwise set of permissions the app or bot has within the channel the interaction was sent from. Locale string `json:"locale,omitempty"` // Selected language of the invoking user. GuildLocale string `json:"guild_locale,omitempty"` // Guild's preferred locale, available if invoked in a guild. Client *Client `json:"-"` // contains filtered or unexported fields }
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
func (ComponentInteraction) Acknowledge ¶
func (itx ComponentInteraction) Acknowledge() error
Sends to discord info that this component was handled successfully without sending anything more.
func (ComponentInteraction) AcknowledgeWithLinearMessage ¶
func (itx ComponentInteraction) AcknowledgeWithLinearMessage(content string, ephemeral bool) error
func (ComponentInteraction) AcknowledgeWithMessage ¶
func (itx ComponentInteraction) AcknowledgeWithMessage(content ResponseMessageData, ephemeral bool) error
func (ComponentInteraction) AcknowledgeWithModal ¶
func (itx ComponentInteraction) AcknowledgeWithModal(modal ResponseModalData) error
type ComponentInteractionData ¶
type ComponentInteractionData struct { CustomID string `json:"custom_id"` Type ComponentType `json:"component_type"` Values []string `json:"values,omitempty"` Resolved *InteractionDataResolved `json:"resolved,omitempty"` }
type ComponentRow ¶
type ComponentRow struct { Type ComponentType `json:"type"` // Always 1 Components []*Component `json:"components"` }
https://discord.com/developers/docs/interactions/message-components#action-rows
type ComponentType ¶
type ComponentType uint8
const ( ROW_COMPONENT_TYPE ComponentType = iota + 1 BUTTON_COMPONENT_TYPE SELECT_MENU_COMPONENT_TYPE TEXT_INPUT_COMPONENT_TYPE USER_SELECT_COMPONENT_TYPE ROLE_SELECT_COMPONENT_TYPE MENTIONABLE_SELECT_COMPONENT_TYPE CHANNEL_SELECT_COMPONENT_TYPE )
https://discord.com/developers/docs/interactions/message-components#component-object-component-types
type Embed ¶
type Embed struct { Title string `json:"title,omitempty"` URL string `json:"url,omitempty"` Author *EmbedAuthor `json:"author,omitempty"` Color uint32 `json:"color,omitempty"` Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"` Description string `json:"description,omitempty"` Fields []*EmbedField `json:"fields,omitempty"` Image *EmbedImage `json:"image,omitempty"` Video *EmbedVideo `json:"video,omitempty"` Provider *EmbedProvider `json:"provider,omitempty"` Timestamp *time.Time `json:"timestamp,omitempty"` }
https://discord.com/developers/docs/resources/channel#embed-object-embed-structure (always rich embed type)
type EmbedAuthor ¶
type EmbedAuthor struct { IconURL string `json:"icon_url,omitempty"` Name string `json:"name,omitempty"` URL string `json:"url,omitempty"` }
https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure
type EmbedField ¶
type EmbedField struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` Inline bool `json:"inline,omitempty"` }
https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure
type EmbedFooter ¶
type EmbedFooter struct {}
https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure
type EmbedImage ¶
type EmbedImage struct { URL string `json:"url"` ProxyURL string `json:"proxy_url,omitempty"` Width uint `json:"width,omitempty"` Height uint `json:"height,omitempty"` }
https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure
type EmbedProvider ¶
https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure
type EmbedThumbnail ¶
type EmbedThumbnail struct { URL string `json:"url"` ProxyURL string `json:"proxy_url,omitempty"` Width uint `json:"width,omitempty"` Height uint `json:"height,omitempty"` }
https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure
type EmbedVideo ¶
type EmbedVideo struct { URL string `json:"url,omitempty"` Width uint `json:"width,omitempty"` Height uint `json:"height,omitempty"` }
https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure
type Emoji ¶
type Emoji struct { ID Snowflake `json:"id,omitempty"` Name string `json:"name"` Roles []Snowflake `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"` }
https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure
type InteractionDataResolved ¶
type InteractionDataResolved struct { Users map[Snowflake]*User `json:"users,omitempty"` Members map[Snowflake]*Member `json:"members,omitempty"` Roles map[Snowflake]*Role `json:"roles,omitempty"` Channels map[Snowflake]*PartialChannel `json:"channels,omitempty"` Messages map[Snowflake]*Message `json:"messages,omitempty"` Attachments map[Snowflake]*Attachment `json:"attachments,omitempty"` }
type InteractionType ¶
type InteractionType uint8
const ( PING_INTERACTION_TYPE InteractionType = iota + 1 APPLICATION_COMMAND_INTERACTION_TYPE MESSAGE_COMPONENT_INTERACTION_TYPE APPLICATION_COMMAND_AUTO_COMPLETE_INTERACTION_TYPE MODAL_SUBMIT_INTERACTION_TYPE )
type InteractionTypeExtractor ¶
type InteractionTypeExtractor struct {
Type InteractionType `json:"type"`
}
Used only for partial JSON parsing.
type Language ¶
type Language string
https://discord.com/developers/docs/reference#locales
const ( DANISH_LANGUAGE Language = "da" GERMAN_LANGUAGE Language = "de" ENGLISH_UK_LANGUAGE Language = "en-GB" ENGLISH_US_LANGUAGE Language = "en-US" SPANISH_LANGUAGE Language = "es-ES" FRENCH_LANGUAGE Language = "fr" CROATIAN_LANGUAGE Language = "hr" ITALIAN_LANGUAGE Language = "it" LITHUANIAN_LANGUAGE Language = "lt" HUNGARIAN_LANGUAGE Language = "hu" DUTCH_LANGUAGE Language = "nl" NORWEGIAN_LANGUAGE Language = "no" POLISH_LANGUAGE Language = "pl" PORTUGUESE_BR_LANGUAGE Language = "pt-BR" ROMANIAN_LANGUAGE Language = "ro" FINNISH_LANGUAGE Language = "fi" SWEDISH_LANGUAGE Language = "sv-SE" VIETNAMESE_LANGUAGE Language = "vi" TURKISH_LANGUAGE Language = "tr" CHECH_LANGUAGE Language = "cs" GREEK_LANGUAGE Language = "el" BULGARIAN_LANGUAGE Language = "bg" RUSSIAN_LANGUAGE Language = "ru" UKRAINIAN_LANGUAGE Language = "uk" HINDI_LANGUAGE Language = "hi" THAI_LANGUAGE Language = "th" CHINESE_CHINA_LANGUAGE Language = "zh-CN" JAPANESE_LANGUAGE Language = "ja" CHINESE_TAIWAN_LANGUAGE Language = "zh-TW" KOREAN_LANGUAGE Language = "ko" )
type Member ¶
type Member struct { User *User `json:"user,omitempty"` Nickname string `json:"nick,omitempty"` GuildAvatarHash string `json:"avatar,omitempty"` // Hash code used to access member's custom, guild profile. Call Member.GuildAvatarURL to get direct url. RoleIDs []Snowflake `json:"roles"` JoinedAt *time.Time `json:"joined_at,omitempty"` PremiumSince *time.Time `json:"premium_since,omitempty"` Dead bool `json:"deaf"` Mute bool `json:"mute"` Flags uint64 `json:"flags"` Pending bool `json:"pending,omitempty"` PermissionFlags uint64 `json:"permissions,string"` CommunicationDisabledUntil *time.Time `json:"communication_disabled_until,omitempty"` GuildID Snowflake `json:"-"` }
https://discord.com/developers/docs/resources/guild#guild-member-object-guild-member-structure
func (Member) GuildAvatarURL ¶
Returns a direct url to members's guild specific avatar. It'll return empty string if targeted member don't use custom avatar for that server.
type Message ¶
type Message struct { ID Snowflake `json:"id"` ChannelID Snowflake `json:"channel_id"` Author *User `json:"author,omitempty"` Content string `json:"content,omitempty"` Timestamp *time.Time `json:"timestamp"` EditedTimestamp *time.Time `json:"edited_timestamp,omitempty"` TTS bool `json:"tts"` MentionEveryone bool `json:"mention_everyone"` Mentions []*User `json:"mentions"` MentionRoles []*Snowflake `json:"mention_roles"` MentionChannels []*ChannelMention `json:"mention_channels,omitempty"` Embeds []*Embed `json:"embeds"` Reactions []*Reaction `json:"reactions,omitempty"` Pinned bool `json:"pinned"` WebhookID Snowflake `json:"webhook_id,omitempty"` Type uint `json:"type,omitempty"` // https://discord.com/developers/docs/resources/channel#message-object-message-types ApplicationID Snowflake `json:"application_id,omitempty"` MessageReference *MessageReference `json:"message_reference,omitempty"` Flags uint64 `json:"flags,omitempty"` ReferencedMessage *Message `json:"referenced_message,omitempty"` Interaction *MessageInteraction `json:"interaction,omitempty"` Components []*ComponentRow `json:"components,omitempty"` StickerItems []*StickerItem `json:"sticker_items,omitempty"` }
https://discord.com/developers/docs/resources/channel#message-object-message-structure
type MessageInteraction ¶
type MessageInteraction struct { ID Snowflake `json:"id"` Type InteractionType `json:"type"` Name string `json:"name"` User User `json:"user"` Member *Member `json:"member,omitempty"` }
type MessageReference ¶
type ModalInteraction ¶
type ModalInteraction struct { ID Snowflake `json:"id"` ApplicationID Snowflake `json:"application_id"` Type InteractionType `json:"type"` Data ModalInteractionData `json:"data"` GuildID Snowflake `json:"guild_id,omitempty"` ChannelID Snowflake `json:"channel_id,omitempty"` Member *Member `json:"member,omitempty"` User *User `json:"user,omitempty"` Token string `json:"token"` // Temporary token used for responding to the interaction. It's not the same as bot/app token. Version uint8 `json:"version"` // Read-only property, always = 1. PermissionFlags uint64 `json:"app_permissions,string"` // Bitwise set of permissions the app or bot has within the channel the interaction was sent from. Locale string `json:"locale,omitempty"` // Selected language of the invoking user. GuildLocale string `json:"guild_locale,omitempty"` // Guild's preferred locale, available if invoked in a guild. Client *Client `json:"-"` // contains filtered or unexported fields }
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
func (ModalInteraction) Acknowledge ¶
func (itx ModalInteraction) Acknowledge() error
Sends to discord info that this component was handled successfully without sending anything more.
func (ModalInteraction) AcknowledgeWithLinearMessage ¶
func (itx ModalInteraction) AcknowledgeWithLinearMessage(content string, ephemeral bool) error
func (ModalInteraction) AcknowledgeWithMessage ¶
func (itx ModalInteraction) AcknowledgeWithMessage(response ResponseMessageData, ephemeral bool) error
func (ModalInteraction) AcknowledgeWithModal ¶
func (itx ModalInteraction) AcknowledgeWithModal(modal ResponseModalData) error
func (ModalInteraction) GetInputValue ¶
func (itx ModalInteraction) GetInputValue(customID string) string
Returns value of any type. It will return empty string on no value or empty value.
type ModalInteractionData ¶
type ModalInteractionData struct { CustomID string `json:"custom_id"` Components []ComponentRow `json:"components"` }
type NitroType ¶
type NitroType uint8
https://discord.com/developers/docs/resources/user#user-object-premium-types
type OptionType ¶
type OptionType uint8
const ( SUB_OPTION_TYPE OptionType = iota + 1 STRING_OPTION_TYPE INTEGER_OPTION_TYPE BOOLEAN_OPTION_TYPE USER_OPTION_TYPE CHANNEL_OPTION_TYPE ROLE_OPTION_TYPE MENTIONABLE_OPTION_TYPE NUMBER_OPTION_TYPE ATTACHMENT_OPTION_TYPE )
type PartialChannel ¶
type PartialChannel struct { ID Snowflake `json:"id"` Name string `json:"name"` PermissionFlags uint64 `json:"permissions,string"` Type ChannelType `json:"type"` }
https://discord.com/developers/docs/resources/channel#channel-object
type PartialEmoji ¶
type PartialEmoji struct { ID Snowflake `json:"id,omitempty"` Name string `json:"name"` Animated bool `json:"animated,omitempty"` }
https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure
type Reaction ¶
type Reaction struct { Count uint `json:"count"` Me bool `json:"me"` Emoji *PartialEmoji `json:"emoji"` }
https://discord.com/developers/docs/resources/channel#reaction-object-reaction-structure
type ResponseAutoComplete ¶
type ResponseAutoComplete struct { Type ResponseType `json:"type"` Data *ResponseAutoCompleteData `json:"data,omitempty"` }
type ResponseAutoCompleteData ¶
type ResponseAutoCompleteData struct {
Choices []Choice `json:"choices,omitempty"`
}
type ResponseMessage ¶
type ResponseMessage struct { Type ResponseType `json:"type"` Data *ResponseMessageData `json:"data,omitempty"` }
type ResponseMessageData ¶
type ResponseMessageData struct { TTS bool `json:"tts,omitempty"` Content string `json:"content,omitempty"` Embeds []*Embed `json:"embeds,omitempty"` AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` Flags uint64 `json:"flags,omitempty"` Components []*ComponentRow `json:"components,omitempty"` }
type ResponseModal ¶
type ResponseModal struct { Type ResponseType `json:"type"` Data *ResponseModalData `json:"data,omitempty"` }
type ResponseModalData ¶
type ResponseModalData struct { CustomID string `json:"custom_id"` Title string `json:"title"` Components []*ComponentRow `json:"components,omitempty"` }
type ResponseType ¶
type ResponseType uint8
const ( PONG_RESPONSE_TYPE ResponseType = iota + 1 ACKNOWLEDGE_RESPONSE_TYPE CHANNEL_MESSAGE_RESPONSE_TYPE CHANNEL_MESSAGE_WITH_SOURCE_RESPONSE_TYPE DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE_RESPONSE_TYPE DEFERRED_UPDATE_MESSAGE_RESPONSE_TYPE // Only valid for component-based interactions. UPDATE_MESSAGE_RESPONSE_TYPE // Only valid for component-based interactions. AUTOCOMPLETE_RESPONSE_TYPE MODAL_RESPONSE_TYPE // Not available for MODAL_SUBMIT and PING interactions. LAUNCH_ACTIVITY_RESPONSE_TYPE // Launch the Activity associated with the app. Only available for apps with Activities enabled. )
type RestClient ¶
type RestClient struct { HTTPClient *http.Client Token string MaxRetries uint8 // contains filtered or unexported fields }
func NewRestClient ¶
func NewRestClient(token string) *RestClient
func (*RestClient) Request ¶
func (rest *RestClient) Request(method string, route string, jsonPayload interface{}) ([]byte, error)
func (*RestClient) RequestWithFiles ¶
type Role ¶
type Role struct { ID Snowflake `json:"id"` Name string `json:"name"` Color uint32 `json:"color"` // Integer representation of hexadecimal color code. Roles without colors (color == 0) do not count towards the final computed color in the user list. Hoist bool `json:"hoist"` // Whether this role is pinned in the user listing. IconHash string `json:"icon,omitempty"` UnicodeEmoji string `json:"unicode_emoji,omitempty"` Position uint8 `json:"position"` PermissionFlags uint64 `json:"permissions,string"` Managed bool `json:"managed"` // Whether this role is managed by an integration. Mentionable bool `json:"mentionable"` // Whether this role is mentionable. Tags *RoleTag `json:"tags,omitempty"` }
https://discord.com/developers/docs/topics/permissions#role-object-role-structure
type RoleTag ¶
type RoleTag struct { BotID Snowflake `json:"bot_id,omitempty"` IntegrationID Snowflake `json:"integration_id,omitempty"` // The id of the integration this role belongs to. PremiumSubscriber bool `json:"premium_subscriber,omitempty"` // Whether this is the guild's Booster role. SubscriptionListingID Snowflake `json:"subscription_listing_id,omitempty"` // The id of this role's subscription sku and listing. AvailableForPurchase bool `json:"available_for_purchase,omitempty"` GuildConnections bool `json:"guild_connections,omitempty"` // Whether this role is a guild's linked role. }
https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure
type SelectMenuOption ¶
type SelectMenuOption struct { Label string `json:"label,omitempty"` // Text label that appears on the option label, max 80 characters. Description string `json:"description,omitempty"` // An additional description of the option, max 100 characters. Emoji *PartialEmoji `json:"emoji,omitempty"` Value string `json:"value"` // Value to return back to app once clicked, max 100 characters. Default bool `json:"default"` // Whether to render this option as selected by default. }
type Snowflake ¶
type Snowflake uint64
Snowflake represents a Discord's id snowflake.
func EnvToSnowflake ¶
Shortcut to calling os.Getenv method and casting to Snowflake.
func StringToSnowflake ¶
func (Snowflake) CreationTimestamp ¶
func (Snowflake) MarshalJSON ¶
func (*Snowflake) UnmarshalJSON ¶
type StickerFormatType ¶
type StickerFormatType uint8
https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types
const ( PNG_STICKER_FORMAT_TYPE StickerFormatType = iota + 1 APNG_STICKER_FORMAT_TYPE LOTTIE_STICKER_FORMAT_TYPE GIF_STICKER_FORMAT_TYPE )
type StickerItem ¶
type StickerItem struct { ID Snowflake `json:"id"` Name string `json:"name"` FormatType StickerFormatType `json:"format_type"` }
https://discord.com/developers/docs/resources/sticker#sticker-item-object-sticker-item-structure
type TextInputStyle ¶
type TextInputStyle uint8
https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-styles
const ( SHORT_TEXT_INPUT_STYLE TextInputStyle = iota + 1 // A single-line input. PARAGRAPH_TEXT_INPUT_STYLE // A multi-line input. )
type User ¶
type User struct { ID Snowflake `json:"id"` Username string `json:"username"` GlobalName string `json:"global_name,omitempty"` // User's display name, if it is set. For bots, this is the application name. AvatarHash string `json:"avatar,omitempty"` // Hash code used to access user's profile. Call User.AvatarURL to get direct url. Bot bool `json:"bot,omitempty"` MFA bool `json:"mfa_enabled,omitempty"` BannerHash string `json:"banner,omitempty"` // Hash code used to access user's baner. Call User.BannerURL to get direct url. AccentColor uint32 `json:"accent_color,omitempty"` // User's banner color, encoded as an integer representation of hexadecimal color code. Locale string `json:"locale,omitempty"` PremiumType NitroType `json:"premium_type,omitempty"` PublicFlags uint64 `json:"public_flags,omitempty"` // (Same as regular flags) }
https://discord.com/developers/docs/resources/user#user-object-user-structure
func (User) AvatarURL ¶
Returns a direct url to user's avatar. It'll return url to default Discord's avatar if targeted user don't use avatar.