Documentation
¶
Index ¶
- Constants
- func DiscordAPIBaseURL() string
- func DiscordCDNBaseURL() string
- func FindInteractiveComponent[CC AnyComponent, T InteractiveComponent](components []CC, filter func(T) bool) (component T, found bool)
- func UpdateDiscordAPIBaseURL(url string)
- func UpdateDiscordCDNBaseURL(url string)
- type AccessoryComponent
- type ActionRowChildComponent
- type ActionRowComponent
- type Activity
- type ActivityType
- type AllowedMentions
- type AllowedMentionsType
- type AnyComponent
- type ApplicationIntegrationType
- type Attachment
- type AttachmentFlags
- type AvatarDecoration
- type BaseClient
- func (client *BaseClient) AwaitComponent(customIDs []string, timeout time.Duration, ...) error
- func (client *BaseClient) AwaitModal(customIDs []string, timeout time.Duration, ...) error
- func (client *BaseClient) ConsumeEntitlement(entitlementID Snowflake) error
- func (client *BaseClient) CreateTestEntitlement(payload TestEntitlementPayload) error
- func (client *BaseClient) CrosspostMessage(channelID Snowflake, messageID Snowflake) error
- func (client *BaseClient) DeleteCommand(name string)
- func (client *BaseClient) DeleteComponent(customIDs []string) error
- func (client *BaseClient) DeleteMessage(channelID Snowflake, messageID Snowflake) error
- func (client *BaseClient) DeleteModal(customIDs []string) error
- func (client *BaseClient) DeleteTestEntitlement(entitlementID Snowflake) error
- func (client *BaseClient) EditMessage(channelID Snowflake, messageID Snowflake, content Message) error
- func (client *BaseClient) FetchEntitlement(entitlementID Snowflake) (Entitlement, error)
- func (client *BaseClient) FetchEntitlementsPage(queryFilter string) ([]Entitlement, error)
- func (client *BaseClient) FetchMember(guildID Snowflake, memberID Snowflake) (Member, error)
- func (client *BaseClient) FetchUser(id Snowflake) (User, error)
- func (client *BaseClient) FindCommand(cmdName string) (Command, bool)
- func (client *BaseClient) RegisterCommand(cmd Command) error
- func (client *BaseClient) RegisterComponent(customIDs []string, handler func(ComponentInteraction)) error
- func (client *BaseClient) RegisterModal(customID string, handler func(ModalInteraction)) error
- func (client *BaseClient) RegisterSubCommand(subCommand Command, parentCommandName string) error
- func (client *BaseClient) RegisteredCommands() iter.Seq2[string, Command]
- func (client *BaseClient) RegisteredStaticComponents() iter.Seq[string]
- func (client *BaseClient) RegisteredStaticModals() iter.Seq[string]
- func (client *BaseClient) SendLinearMessage(channelID Snowflake, content string) (Message, error)
- func (client *BaseClient) SendMessage(channelID Snowflake, message Message, files []File) (Message, error)
- func (client *BaseClient) SendPrivateMessage(userID Snowflake, content Message, files []File) (Message, error)
- func (client *BaseClient) SyncCommandsWithDiscord(guildIDs []Snowflake, whitelist []string, reverseMode bool) error
- type BaseClientOptions
- type BitSet
- type Bucket
- type ButtonComponent
- type ButtonStyle
- type ChannelMention
- type ChannelType
- type CheckboxComponent
- type CheckboxGroupComponent
- type CheckboxGroupOption
- type Command
- type CommandHandlerType
- type CommandInteraction
- func (itx *CommandInteraction) Defer(ephemeral bool) error
- func (itx *CommandInteraction) DeleteFollowUp(messageID Snowflake) error
- func (itx *CommandInteraction) DeleteReply() error
- func (itx *CommandInteraction) EditFollowUp(messageID Snowflake, content ResponseMessageData) error
- func (itx *CommandInteraction) EditLinearFollowUp(messageID Snowflake, content string) error
- func (itx *CommandInteraction) EditLinearReply(content string, ephemeral bool) 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) SendFollowUp(content ResponseMessageData, ephemeral bool) (Message, error)
- func (itx *CommandInteraction) SendFollowUpWithFiles(content ResponseMessageData, ephemeral bool, files []File) (Message, error)
- func (itx *CommandInteraction) SendLinearFollowUp(content string, ephemeral bool) (Message, error)
- func (itx *CommandInteraction) SendLinearFollowUpWithFiles(content string, ephemeral bool, files []File) (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 []File) error
- type CommandInteractionData
- type CommandInteractionOption
- type CommandOption
- type CommandOptionChoice
- type CommandType
- type ComponentInteraction
- func (itx *ComponentInteraction) Acknowledge() error
- func (itx *ComponentInteraction) AcknowledgeWithLinearMessage(content string, ephemeral bool) error
- func (itx *ComponentInteraction) AcknowledgeWithLinearUpdate(content string) error
- func (itx *ComponentInteraction) AcknowledgeWithMessage(reply ResponseMessageData, ephemeral bool) error
- func (itx *ComponentInteraction) AcknowledgeWithModal(modal ResponseModalData) error
- func (itx *ComponentInteraction) AcknowledgeWithUpdate(reply ResponseMessageData) error
- type ComponentInteractionData
- type ComponentType
- type ContainerChildComponent
- type ContainerComponent
- type ContentComponent
- type CreateGuildEventData
- type DefaultValueOption
- type DefaultValueType
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFlags
- type EmbedFooter
- type EmbedImage
- type EmbedMediaFlags
- type EmbedProvider
- type EmbedThumbnail
- type EmbedVideo
- type Emoji
- type Entitlement
- type EntitlementOwnerType
- type EntitlementType
- type EventName
- type EventPacket
- type ExplicitContentFilter
- type File
- type FileComponent
- type FileUploadComponent
- type GatewayBot
- type GatewayClient
- type GatewayClientOptions
- type Guild
- type HTTPClient
- type HTTPClientOptions
- type HeartbeatEvent
- type HelloEventData
- type IdentifyEvent
- type IdentifyPayloadData
- type IdentifyPayloadDataProperties
- type Interaction
- type InteractionContextType
- type InteractionDataResolved
- func (r *InteractionDataResolved) ResolveAttachment(id Snowflake) Attachment
- func (r *InteractionDataResolved) ResolveChannel(id Snowflake) PartialChannel
- func (r *InteractionDataResolved) ResolveMember(id Snowflake) Member
- func (r *InteractionDataResolved) ResolveMessage(id Snowflake) Message
- func (r *InteractionDataResolved) ResolveRole(id Snowflake) (Role, bool)
- func (r *InteractionDataResolved) ResolveUser(id Snowflake) User
- type InteractionType
- type InteractiveComponent
- type LabelChildComponent
- type LabelComponent
- type Language
- type LayoutComponent
- type MFALevel
- type MediaGalleryComponent
- type MediaGalleryItem
- type Member
- type MemberFlags
- type Message
- type MessageComponent
- type MessageFlags
- type MessageInteractionMetadata
- type MessageNotificationLevel
- type MessageReference
- type MessageReferenceType
- type MessageType
- type ModalComponent
- type ModalInteraction
- func (itx *ModalInteraction) Acknowledge() error
- func (itx *ModalInteraction) AcknowledgeWithLinearMessage(content string, ephemeral bool) error
- func (itx *ModalInteraction) AcknowledgeWithLinearUpdate(content string) error
- func (itx *ModalInteraction) AcknowledgeWithMessage(response ResponseMessageData, ephemeral bool) error
- func (itx *ModalInteraction) AcknowledgeWithModal(modal ResponseModalData) error
- func (itx *ModalInteraction) AcknowledgeWithUpdate(response ResponseMessageData) error
- func (itx *ModalInteraction) Defer(ephemeral bool) error
- func (itx *ModalInteraction) GetCheckboxGroupValues(customID string) []string
- func (itx *ModalInteraction) GetCheckboxValue(customID string) (bool, bool)
- func (itx *ModalInteraction) GetFileUploadAttachments(customID string) []Attachment
- func (itx *ModalInteraction) GetFileUploadValues(customID string) []Snowflake
- func (itx *ModalInteraction) GetInputValue(customID string) string
- func (itx *ModalInteraction) GetRadioGroupValue(customID string) (string, bool)
- func (itx *ModalInteraction) GetSelectValues(customID string) []Snowflake
- func (itx *ModalInteraction) GetStringSelectValues(customID string) []string
- func (itx *ModalInteraction) SendFollowUp(content ResponseMessageData, ephemeral bool) (Message, error)
- func (itx *ModalInteraction) SendLinearFollowUp(content string, ephemeral bool) (Message, error)
- type ModalInteractionData
- type NSFWLevel
- type NitroType
- type Nonce
- type Opcode
- type OptionType
- type PartialChannel
- type PermissionFlags
- type Poll
- type PollAnswer
- type PollMedia
- type PoolAnswerCounts
- type PoolLayoutType
- type PoolResult
- type PremiumTier
- type RadioGroupComponent
- type RadioGroupOption
- type RateLimiter
- type RateLimiterOptions
- type Reaction
- type ReactionCountDetails
- type ReadyEventData
- type Response
- type ResponseAutoComplete
- type ResponseAutoCompleteData
- type ResponseMessage
- type ResponseMessageData
- type ResponseModal
- type ResponseModalData
- type ResponseType
- type Rest
- func (rest *Rest) BufferJSON(jsonPayload any) (io.ReadSeeker, error)
- func (rest *Rest) DirectRequest(method, route string, body io.ReadSeeker, contentType string, ...) error
- func (rest *Rest) DirectRequestContext(ctx context.Context, method, route string, body io.ReadSeeker, ...) error
- func (rest *Rest) Request(method, route string, jsonPayload any, into any) error
- func (rest *Rest) RequestBytes(method, route string, jsonPayload any) ([]byte, error)
- func (rest *Rest) RequestBytesContext(ctx context.Context, method, route string, jsonPayload any) ([]byte, error)
- func (rest *Rest) RequestContext(ctx context.Context, method, route string, jsonPayload any, into any) error
- func (rest *Rest) RequestWithFiles(method string, route string, jsonPayload any, files []File, into any) error
- func (rest *Rest) RequestWithFilesContext(ctx context.Context, method string, route string, jsonPayload any, ...) error
- type RestOptions
- type ResumeEvent
- type ResumeEventData
- type Role
- type RoleColors
- type RoleFlags
- type RoleTag
- type SectionComponent
- type SelectComponent
- type SelectMenuOption
- type SeparatorComponent
- type SessionStartLimit
- type Shard
- type ShardManager
- func (m *ShardManager) AllShardDetails() ([]ShardState, []time.Duration)
- func (m *ShardManager) Broadcast(jsonStruct any)
- func (m *ShardManager) Send(shardID uint16, jsonStruct any)
- func (m *ShardManager) ShardDetails(shardID uint16) (ShardState, time.Duration, error)
- func (m *ShardManager) Start(ctx context.Context, intents uint32, forcedShardCount uint16, ...) error
- func (m *ShardManager) Status() map[uint16]ShardState
- func (m *ShardManager) UpdateStatus(statusGeneratorFn func(shardID uint16) *UpdatePresenceEvent)
- type ShardState
- type SharedMap
- func (sm *SharedMap[K, V]) Delete(key K)
- func (sm *SharedMap[K, V]) Entries() iter.Seq2[K, V]
- func (sm *SharedMap[K, V]) FilterKeys(filter func(key K, value V) bool, limit int) []K
- func (sm *SharedMap[K, V]) FilterMap(filter func(key K, value V) bool, limit int) *SharedMap[K, V]
- func (sm *SharedMap[K, V]) FilterValues(filter func(key K, value V) bool, limit int) []V
- func (sm *SharedMap[K, V]) Get(key K) (V, bool)
- func (sm *SharedMap[K, V]) Has(key K) bool
- func (sm *SharedMap[K, V]) Keys() iter.Seq[K]
- func (sm *SharedMap[K, V]) Reset()
- func (sm *SharedMap[K, V]) Set(key K, value V)
- func (sm *SharedMap[K, V]) Size() int
- func (sm *SharedMap[K, V]) Sweep(filter func(key K, value V) bool)
- func (sm *SharedMap[K, V]) Values() iter.Seq[V]
- type Snowflake
- type StatusType
- type StickerFormatType
- type StickerItem
- type StringSelectComponent
- type SystemChannelFlags
- type TestEntitlementPayload
- type TextDisplayComponent
- type TextInputComponent
- type TextInputStyle
- type ThumbnailComponent
- type UnavailableGuild
- type UnfurledMediaItem
- type UnfurledMediaItemFlags
- type UpdatePresenceEvent
- type UpdatePresenceEventData
- type User
- type UserFlags
- type VerificationLevel
Constants ¶
const ( DISCORD_EPOCH = 1420070400000 // Discord epoch in milliseconds USER_AGENT = "DiscordApp https://github.com/amatsagu/tempest" GATEWAY_AGENT = "tempest" CONTENT_TYPE_JSON = "application/json" CONTENT_TYPE_OCTET_STREAM = "application/octet-stream" CONTENT_MULTIPART_JSON_DESCRIPTION = `form-data; name="payload_json"` MAX_REQUEST_BODY_SIZE = 1024 * 1024 // Interaction HTTP request body limit: 1 MiB. MAX_FILE_UPLOAD_SIZE = 10 * 1024 * 1024 // 10 MB ROOT_PLACEHOLDER = "-" // Gateway events such as GUILD_CREATE can legitimately exceed the 1 MiB // interaction body limit. This is a hard ceiling checked while reading, not // an upfront allocation, so it only costs memory for messages actually sent. MAX_GATEWAY_MESSAGE_SIZE = 16 * 1024 * 1024 // 16 MiB GATEWAY_READ_TIMEOUT = 90 * time.Second GATEWAY_WRITE_TIMEOUT = 10 * time.Second GATEWAY_HANDSHAKE_TIMEOUT = 30 * time.Second GATEWAY_RECONNECT_DELAY = 1 * time.Second GATEWAY_DIAL_RETRY_DELAY = 5 * time.Second REST_DIAL_TIMEOUT = 5 * time.Second REST_KEEP_ALIVE = 30 * time.Second REST_MAX_IDLE_CONNS = 256 REST_MAX_IDLE_CONNS_PER_HOST = 64 REST_IDLE_CONN_TIMEOUT = 90 * time.Second REST_TLS_HANDSHAKE_TIMEOUT = 10 * time.Second REST_EXPECT_CONTINUE_TIMEOUT = time.Second REST_FORCE_ATTEMPT_HTTP2 = true REST_DEFAULT_MAX_WAIT_TIME = 10 * time.Second REST_DEFAULT_MAX_RETRIES = 3 REST_DEFAULT_RETRY_THRESHOLD = 60 RATE_LIMITER_SWEEP_INTERVAL = 30 * time.Minute RATE_LIMITER_SWEEP_THRESHOLD = 2500 RATE_LIMITER_SWEEP_EVERY = 50 RATE_LIMITER_RESET_TIME_FUDGE = 100 * time.Millisecond )
const ( SUPPRESS_JOIN_NOTIFICATIONS_SYSTEM_FLAG = 1 << iota SUPPRESS_PREMIUM_SUBSCRIPTIONS_SYSTEM_FLAG SUPPRESS_GUILD_REMINDER_NOTIFICATIONS_SYSTEM_FLAG SUPPRESS_JOIN_NOTIFICATION_REPLIES_SYSTEM_FLAG SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATIONS_SYSTEM_FLAG SUPPRESS_ROLE_SUBSCRIPTION_PURCHASE_NOTIFICATION_REPLIES_SYSTEM_FLAG )
Variables ¶
This section is empty.
Functions ¶
func DiscordAPIBaseURL ¶ added in v1.5.0
func DiscordAPIBaseURL() string
func DiscordCDNBaseURL ¶ added in v1.5.0
func DiscordCDNBaseURL() string
func FindInteractiveComponent ¶ added in v1.3.0
func FindInteractiveComponent[CC AnyComponent, T InteractiveComponent](components []CC, filter func(T) bool) (component T, found bool)
Recursively scans the components array for the first interactive component that satisfies filter.
Warning - This function can traverse arbitrarily deep nested component trees & uses frequent type assertions, reducing overall performance. Prefer checking individual components for interactions with smaller numbers of components.
func UpdateDiscordAPIBaseURL ¶ added in v1.5.0
func UpdateDiscordAPIBaseURL(url string)
func UpdateDiscordCDNBaseURL ¶ added in v1.5.0
func UpdateDiscordCDNBaseURL(url string)
Types ¶
type AccessoryComponent ¶ added in v1.3.0
type AccessoryComponent interface {
AnyComponent
// contains filtered or unexported methods
}
AccessoryComponent is a special subset of components that can be used as SectionComponent accessories. Only one accessory is allowed per section.
Currently valid types: ButtonComponent & ThumbnailComponent.
https://docs.discord.com/developers/components/reference#section-section-structure
type ActionRowChildComponent ¶ added in v1.5.0
type ActionRowChildComponent interface {
AnyComponent
// contains filtered or unexported methods
}
ActionRowChildComponent represents components that can be used inside an ActionRowComponent.
Currently valid types: ButtonComponent, StringSelectComponent and SelectComponent (user/role/mentionable/channel selects).
https://docs.discord.com/developers/components/reference#action-row-action-row-child-components
type ActionRowComponent ¶ added in v1.3.0
type ActionRowComponent struct {
Components []ActionRowChildComponent `json:"components,omitzero"` // Up to 5 interactive [ButtonComponent]s or a single [SelectComponent]
ID uint32 `json:"id,omitzero"`
Type ComponentType `json:"type"` // Always = ACTION_ROW_COMPONENT_TYPE (1)
}
An ActionRowComponent groups other related components within a message or modal.
https://docs.discord.com/developers/components/reference#action-row-action-row-structure
func (*ActionRowComponent) UnmarshalJSON ¶ added in v1.3.0
func (c *ActionRowComponent) UnmarshalJSON(data []byte) error
type Activity ¶ added in v1.4.0
type Activity struct {
Name string `json:"name"`
State string `json:"state,omitempty"` // User’s current custom status text (name must be still defined to work)
URL string `json:"url,omitempty"` // Stream URL, only for Streaming type
Type ActivityType `json:"type"`
}
https://docs.discord.com/developers/events/gateway-events#activity-object
Activity only in context of Discord Bot Presence via Gateway.
type ActivityType ¶ added in v1.4.0
type ActivityType uint8
https://docs.discord.com/developers/events/gateway-events#activity-object-activity-types
const ( PLAYING_ACTIVITY_TYPE ActivityType = 0 STREAMING_ACTIVITY_TYPE ActivityType = 1 LISTENING_ACTIVITY_TYPE ActivityType = 2 WATCHING_ACTIVITY_TYPE ActivityType = 3 CUSTOM_ACTIVITY_TYPE ActivityType = 4 COMPETING_ACTIVITY_TYPE ActivityType = 5 )
type AllowedMentions ¶
type AllowedMentions struct {
Parse []AllowedMentionsType `json:"parse,omitzero"`
Roles []Snowflake `json:"roles,omitzero"`
Users []Snowflake `json:"users,omitzero"`
RepliedUser bool `json:"replied_user"`
}
https://docs.discord.com/developers/resources/message#allowed-mentions-object
type AllowedMentionsType ¶ added in v1.2.3
type AllowedMentionsType string
https://docs.discord.com/developers/resources/message#allowed-mentions-object-allowed-mention-types
const ( ALLOWED_ROLE_MENTION_TYPE AllowedMentionsType = "roles" ALLOWED_USERS_MENTION_TYPE AllowedMentionsType = "users" ALLOWED_EVERYONE_MENTION_TYPE AllowedMentionsType = "everyone" )
type AnyComponent ¶ added in v1.3.0
type AnyComponent interface {
// contains filtered or unexported methods
}
AnyComponent is a union interface representing all possible Discord components. All component types must implement this interface.
Avoid using this interface directly; instead look at its child interfaces - MessageComponent, ModalComponent, InteractiveComponent, LabelChildComponent, etc.
func UnmarshalComponent ¶ added in v1.3.0
func UnmarshalComponent(data []byte) (AnyComponent, error)
Inspects the "type" field and returns the proper component struct.
type ApplicationIntegrationType ¶ added in v1.2.3
type ApplicationIntegrationType uint8
const ( GUILD_INSTALL ApplicationIntegrationType = iota USER_INSTALL )
type Attachment ¶
type Attachment struct {
ClipCreatedAt *time.Time `json:"clip_created_at,omitempty"`
URL string `json:"url"`
Waveform string `json:"waveform,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
ContentType string `json:"content_type,omitempty"`
ProxyURL string `json:"proxy_url"`
Placeholder string `json:"placeholder,omitempty"`
FileName string `json:"filename"`
ClipParticipants []User `json:"clip_participants,omitzero"`
ID Snowflake `json:"id"`
Size uint64 `json:"size"`
Flags AttachmentFlags `json:"flags,omitzero"`
DurationSecs float64 `json:"duration_secs,omitzero"`
Height uint32 `json:"height,omitzero"`
Width uint32 `json:"width,omitzero"`
PlaceholderVersion uint32 `json:"placeholder_version,omitzero"`
Ephemeral bool `json:"ephemeral"`
}
https://docs.discord.com/developers/resources/message#attachment-object
type AttachmentFlags ¶ added in v1.11.0
type AttachmentFlags = BitSet
https://docs.discord.com/developers/resources/message#attachment-object-attachment-flags
const ( IS_CLIP_ATTACHMENT_FLAG AttachmentFlags = 1 << 0 IS_THUMBNAIL_ATTACHMENT_FLAG AttachmentFlags = 1 << 1 IS_REMIX_ATTACHMENT_FLAG AttachmentFlags = 1 << 2 IS_SPOILER_ATTACHMENT_FLAG AttachmentFlags = 1 << 3 CONTAINS_EXPLICIT_CONTENT_ATTACHMENT_FLAG AttachmentFlags = 1 << 4 IS_ANIMATED_ATTACHMENT_FLAG AttachmentFlags = 1 << 5 CONTAINS_GORE_CONTENT_ATTACHMENT_FLAG AttachmentFlags = 1 << 6 CONTAINS_SELF_HARM_CONTENT_ATTACHMENT_FLAG AttachmentFlags = 1 << 7 )
type AvatarDecoration ¶ added in v1.2.3
type AvatarDecoration struct {
AssetHash string `json:"asset"` // Hash code used to access user's avatar decoration.
SkuID Snowflake `json:"sku_id"`
}
https://docs.discord.com/developers/resources/user#avatar-decoration-data-object
func (*AvatarDecoration) DecorationURL ¶ added in v1.2.3
func (adc *AvatarDecoration) DecorationURL() string
Returns a direct url to targets's avatar decoration. It'll return empty string if target doesn't use avatar decoration.
type BaseClient ¶ added in v1.4.0
type BaseClient struct {
Rest *Rest
ApplicationID Snowflake
// contains filtered or unexported fields
}
BaseClient is the core tempest entrypoint. It's used to create either HTTP or Gateway clients. You should avoid using base version unless you know what you're doing.
func NewBaseClient ¶ added in v1.4.0
func NewBaseClient(opt BaseClientOptions) *BaseClient
func (*BaseClient) AwaitComponent ¶ added in v1.4.0
func (client *BaseClient) AwaitComponent(customIDs []string, timeout time.Duration, onActionFn func(itx *ComponentInteraction) bool, onTimeoutFn func()) error
Makes client dynamically "listen" incoming component type interactions. When component custom id matches - it'll run onAction callback. If onAction returns true, it means it finished - so it should be instantly removed from memory and onTimeout should never be called then. If onAction returns false - do nothing extra (it remains in map, can be called again or timeout). If it reaches the timeout duration, it stops listening and calls onTimeout (if provided).
Warning! Components handled this way will already be acknowledged.
func (*BaseClient) AwaitModal ¶ added in v1.4.0
func (client *BaseClient) AwaitModal(customIDs []string, timeout time.Duration, onActionFn func(itx *ModalInteraction) bool, onTimeoutFn func()) error
Mirror method to Client.AwaitComponent but for handling modal interactions. Look comment on Client.AwaitComponent and see example bot/app code for more.
func (*BaseClient) ConsumeEntitlement ¶ added in v1.4.0
func (client *BaseClient) ConsumeEntitlement(entitlementID Snowflake) error
For One-Time Purchase consumable SKUs, marks a given entitlement for the user as consumed. The entitlement will have consumed: true when using Client.FetchEntitlements.
https://docs.discord.com/developers/resources/entitlement#consume-an-entitlement
func (*BaseClient) CreateTestEntitlement ¶ added in v1.4.0
func (client *BaseClient) CreateTestEntitlement(payload TestEntitlementPayload) error
https://docs.discord.com/developers/resources/entitlement#create-test-entitlement
func (*BaseClient) CrosspostMessage ¶ added in v1.4.0
func (client *BaseClient) CrosspostMessage(channelID Snowflake, messageID Snowflake) error
func (*BaseClient) DeleteCommand ¶ added in v1.10.0
func (client *BaseClient) DeleteCommand(name string)
Removes a command from the registry. If the command is a subcommand, the name must be formatted as "parentName@subcommandName" (e.g. "inventory@use").
func (*BaseClient) DeleteComponent ¶ added in v1.4.2
func (client *BaseClient) DeleteComponent(customIDs []string) error
Removes previously registered, static components that match any of provided custom IDs.
func (*BaseClient) DeleteMessage ¶ added in v1.4.0
func (client *BaseClient) DeleteMessage(channelID Snowflake, messageID Snowflake) error
func (*BaseClient) DeleteModal ¶ added in v1.4.2
func (client *BaseClient) DeleteModal(customIDs []string) error
Removes previously registered, static modals that match any of provided custom IDs.
func (*BaseClient) DeleteTestEntitlement ¶ added in v1.4.0
func (client *BaseClient) DeleteTestEntitlement(entitlementID Snowflake) error
https://docs.discord.com/developers/resources/entitlement#delete-test-entitlement
func (*BaseClient) EditMessage ¶ added in v1.4.0
func (client *BaseClient) EditMessage(channelID Snowflake, messageID Snowflake, content Message) error
func (*BaseClient) FetchEntitlement ¶ added in v1.4.0
func (client *BaseClient) FetchEntitlement(entitlementID Snowflake) (Entitlement, error)
https://docs.discord.com/developers/resources/entitlement#get-entitlement
func (*BaseClient) FetchEntitlementsPage ¶ added in v1.4.0
func (client *BaseClient) FetchEntitlementsPage(queryFilter string) ([]Entitlement, error)
Returns all entitlements for a given app, active and expired.
By default it will attempt to return all, existing entitlements - provide query filter to control this behavior.
https://docs.discord.com/developers/resources/entitlement#list-entitlements
func (*BaseClient) FetchMember ¶ added in v1.4.0
func (client *BaseClient) FetchMember(guildID Snowflake, memberID Snowflake) (Member, error)
func (*BaseClient) FetchUser ¶ added in v1.4.0
func (client *BaseClient) FetchUser(id Snowflake) (User, error)
func (*BaseClient) FindCommand ¶ added in v1.4.0
func (client *BaseClient) FindCommand(cmdName string) (Command, bool)
func (*BaseClient) RegisterCommand ¶ added in v1.4.0
func (client *BaseClient) RegisterCommand(cmd Command) error
func (*BaseClient) RegisterComponent ¶ added in v1.4.0
func (client *BaseClient) RegisterComponent(customIDs []string, handler 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 (*BaseClient) RegisterModal ¶ added in v1.4.0
func (client *BaseClient) RegisterModal(customID string, handler func(ModalInteraction)) error
Bind function to modal with matching custom id. App will automatically run bound function whenever receiving component interaction with matching custom id.
func (*BaseClient) RegisterSubCommand ¶ added in v1.4.0
func (client *BaseClient) RegisterSubCommand(subCommand Command, parentCommandName string) error
func (*BaseClient) RegisteredCommands ¶ added in v1.10.0
func (client *BaseClient) RegisteredCommands() iter.Seq2[string, Command]
Returns an iterator over all registered command names and their configurations. Subcommands are returned with names formatted as "parentName@subcommandName" (e.g. "inventory@use").
func (*BaseClient) RegisteredStaticComponents ¶ added in v1.10.0
func (client *BaseClient) RegisteredStaticComponents() iter.Seq[string]
Returns an iterator over all registered static component IDs.
func (*BaseClient) RegisteredStaticModals ¶ added in v1.10.0
func (client *BaseClient) RegisteredStaticModals() iter.Seq[string]
Returns an iterator over all registered static modal IDs.
func (*BaseClient) SendLinearMessage ¶ added in v1.4.0
func (client *BaseClient) SendLinearMessage(channelID Snowflake, content string) (Message, error)
func (*BaseClient) SendMessage ¶ added in v1.4.0
func (*BaseClient) SendPrivateMessage ¶ added in v1.4.0
func (client *BaseClient) SendPrivateMessage(userID Snowflake, content Message, files []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 (*BaseClient) SyncCommandsWithDiscord ¶ added in v1.4.0
func (client *BaseClient) SyncCommandsWithDiscord(guildIDs []Snowflake, whitelist []string, reverseMode bool) error
type BaseClientOptions ¶ added in v1.4.0
type BaseClientOptions struct {
// Context is the client lifecycle context used for REST and rate-limiter
// work without a more specific context. It is ignored when
// RestOptions.Context is set. Gateway clients replace it with the context
// passed to ShardManager.Start. HTTP clients should provide their
// server/application context so shutdown also stops post-response work.
Context context.Context
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.
Logger *log.Logger // Optional custom logger. If tracing is enabled, this logger will be used for all internal messages. If none is provided, the default Stdout logger will be used instead.
Token string
DefaultInteractionContexts []InteractionContextType
RestOptions RestOptions
}
type BitSet ¶ added in v1.2.3
type BitSet uint64
Represents combination of discord bit settings, flags, permissions, etc. For example all the user badges or member permissions.
type Bucket ¶ added in v1.9.0
type Bucket struct {
ResetAt time.Time
ID string
Window time.Duration
Remaining int
Limit int
// contains filtered or unexported fields
}
Represents a Discord rate limit bucket.
type ButtonComponent ¶ added in v1.3.0
type ButtonComponent struct {
Emoji *Emoji `json:"emoji,omitzero"` // It may only contain id, name, and animated from regular Emoji struct.
Label string `json:"label,omitzero"`
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id,omitzero"`
URL string `json:"url,omitzero"`
SkuID Snowflake `json:"sku_id,omitzero"` // Identifier for a purchasable SKU, only available when using premium-style buttons. Premium buttons do not send an interaction to your app when clicked.
ID uint32 `json:"id,omitzero"`
Type ComponentType `json:"type"` // Always = BUTTON_COMPONENT_TYPE (2)
Style ButtonStyle `json:"style"`
Disabled bool `json:"disabled,omitzero"`
}
A ButtonComponent displays a clickable element that users can interact with, sending an interaction to your app when pressed.
They must be placed within an ActionRowComponent or a SectionComponent's accessory field, both of which are only valid inside messages.
https://docs.discord.com/developers/components/reference#button-button-structure
type ButtonStyle ¶
type ButtonStyle uint8
https://docs.discord.com/developers/components/reference#button-button-styles
const ( PRIMARY_BUTTON_STYLE ButtonStyle = iota + 1 // blurple (custom_id field is required) SECONDARY_BUTTON_STYLE // grey (custom_id field is required) SUCCESS_BUTTON_STYLE // green (custom_id field is required) DANGER_BUTTON_STYLE // red (custom_id field is required) LINK_BUTTON_STYLE // grey, navigate to URL (url field is required) PREMIUM_BUTTON_STYLE // By default same as primary but will automatically use SKU icon, name & price (sky_id field is required) )
type ChannelMention ¶
type ChannelMention struct {
Name string `json:"name"`
ID Snowflake `json:"id"`
GuildID Snowflake `json:"guild_id"`
Type ChannelType `json:"type"`
}
type ChannelType ¶
type ChannelType uint8
https://docs.discord.com/developers/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 GUILD_MEDIA_CHANNEL_TYPE )
func (ChannelType) MarshalJSON ¶
func (ct ChannelType) MarshalJSON() (p []byte, err error)
type CheckboxComponent ¶ added in v1.6.0
type CheckboxComponent struct {
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id,omitempty"`
ID uint32 `json:"id,omitzero"` // Optional identifier for component
Type ComponentType `json:"type"` // Always = CHECKBOX_COMPONENT_TYPE (23)
Default bool `json:"default,omitzero"` // Whether to render this option as selected by default.
Value bool `json:"value,omitzero"` // The state of the checkbox (true if checked, false if unchecked). Populated on modal submission.
}
A CheckboxComponent displays a single, non-required yes/no style question.
They can only be used inside [LabelComponent]s within modals.
https://docs.discord.com/developers/components/reference#checkbox
type CheckboxGroupComponent ¶ added in v1.6.0
type CheckboxGroupComponent struct {
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id,omitempty"`
Options []CheckboxGroupOption `json:"options,omitzero"` // The options to show in this checkbox group; must be between 1 and 10 options.
Values []string `json:"values,omitzero"` // The values of the selected options. Populated on modal submission.
ID uint32 `json:"id,omitzero"` // Optional identifier for component
Type ComponentType `json:"type"` // Always = CHECKBOX_GROUP_COMPONENT_TYPE (22)
MinValues uint8 `json:"min_values,omitzero"` // The minimum number of options that must be chosen; defaults to 1 and must be between 0 and 10. Can only be 0 if required is set to false.
MaxValues uint8 `json:"max_values,omitzero"` // The maximum number of options that can be chosen; must be between 1 and 10.
Required bool `json:"required"` // Whether a selection is required to submit the modal (defaults to true).
}
A CheckboxGroupComponent displays a list of one or more options selectable via checkboxes.
They can only be used inside [LabelComponent]s within modals.
https://docs.discord.com/developers/components/reference#checkbox-group
type CheckboxGroupOption ¶ added in v1.6.0
type CheckboxGroupOption struct {
Value string `json:"value"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
Default bool `json:"default,omitzero"` // Whether to render this option as selected by default.
}
https://docs.discord.com/developers/components/reference#checkbox-group-option-structure
type Command ¶
type Command struct {
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.
AutoCompleteHandler func(itx CommandInteraction) []CommandOptionChoice `json:"-"` // Custom handler for auto complete interactions. It's a Tempest specific field.
DescriptionLocalizations map[Language]string `json:"description_localizations,omitzero"`
NameLocalizations map[Language]string `json:"name_localizations,omitzero"`
Description string `json:"description"`
Name string `json:"name"`
Options []CommandOption `json:"options,omitzero"`
IntegrationTypes []ApplicationIntegrationType `json:"integration_types,omitzero"`
Contexts []InteractionContextType `json:"contexts,omitzero"` // Interaction context(s) where the command can be used, only for globally-scoped commands. By default, all interaction context types included for new commands.
GuildID Snowflake `json:"guild_id,omitzero"`
ID Snowflake `json:"-"` // It's not needed on app side to work.
RequiredPermissions PermissionFlags `json:"default_member_permissions,string,omitzero"` // Set of permissions represented as a bit set that are required from user/member to use command. Set it to 0 to make command unavailable for regular members (guild administrators still can use it).
Version Snowflake `json:"version,omitzero"` // Autoincrementing version identifier updated during substantial record changes.
ApplicationID Snowflake `json:"application_id,omitzero"`
NSFW bool `json:"nsfw,omitzero"` // https://docs.discord.com/developers/interactions/application-commands#age-restricted-commands
Handler CommandHandlerType `json:"handler,omitzero"`
Type CommandType `json:"type,omitzero"`
}
type CommandHandlerType ¶ added in v1.3.0
type CommandHandlerType uint8
const ( APP_COMMAND_HANDLER CommandHandlerType = iota + 1 DISCORD_LAUNCH_ACTIVITY_COMMAND_HANDLER )
type CommandInteraction ¶
type CommandInteraction struct {
Data CommandInteractionData `json:"data"`
Interaction
}
A CommandInteraction represents an interaction received from a user invoking an application command, such as a slash command or a context menu command.
https://docs.discord.com/developers/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) error
func (*CommandInteraction) DeleteReply ¶
func (itx *CommandInteraction) DeleteReply() error
func (*CommandInteraction) EditFollowUp ¶
func (itx *CommandInteraction) EditFollowUp(messageID Snowflake, content ResponseMessageData) error
func (*CommandInteraction) EditLinearFollowUp ¶ added in v1.3.1
func (itx *CommandInteraction) EditLinearFollowUp(messageID Snowflake, content string) error
func (*CommandInteraction) EditLinearReply ¶ added in v1.3.1
func (itx *CommandInteraction) EditLinearReply(content string, ephemeral bool) 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) SendFollowUp ¶
func (itx *CommandInteraction) SendFollowUp(content ResponseMessageData, ephemeral bool) (Message, error)
func (*CommandInteraction) SendFollowUpWithFiles ¶ added in v1.4.0
func (itx *CommandInteraction) SendFollowUpWithFiles(content ResponseMessageData, ephemeral bool, files []File) (Message, error)
func (*CommandInteraction) SendLinearFollowUp ¶ added in v1.3.1
func (itx *CommandInteraction) SendLinearFollowUp(content string, ephemeral bool) (Message, error)
func (*CommandInteraction) SendLinearFollowUpWithFiles ¶ added in v1.4.0
func (*CommandInteraction) SendLinearReply ¶
func (itx *CommandInteraction) SendLinearReply(content string, ephemeral bool) error
func (*CommandInteraction) SendModal ¶
func (itx *CommandInteraction) SendModal(modal ResponseModalData) error
func (*CommandInteraction) SendReply ¶
func (itx *CommandInteraction) SendReply(reply ResponseMessageData, ephemeral bool, files []File) error
Acknowledges the interaction with a message. Set ephemeral = true to make message visible only to target.
type CommandInteractionData ¶
type CommandInteractionData struct {
Resolved *InteractionDataResolved `json:"resolved,omitempty"` // Data that Discord has resolved for the command, such as user and role objects. Fields will only be available to bots with the requisite permissions.
Name string `json:"name"` // The name of the invoked command, not including subcommand names.
Options []CommandInteractionOption `json:"options,omitzero"` // The options and values passed by the user.
ID Snowflake `json:"id"` // The ID of the invoked command.
GuildID Snowflake `json:"guild_id,omitzero"` // The ID of the guild the command was invoked from. Will be null (i.e. 0) if invoked in a DM.
TargetID Snowflake `json:"target_id,omitzero"` // The ID of the user or message targeted by a user or message command from the context menu. Will be empty for slash commands.
Type CommandType `json:"type"` // The type of comamnd that was invoked.
}
A CommandInteractionData represents the data received from a user invoking an application command, such as a slash command or a context menu command.
type CommandInteractionOption ¶
type CommandInteractionOption struct {
Value any `json:"value,omitempty"` // The value provided by the user; will always be of type string, float64 (double/integer) or bool. Mutually exclusive with options.
Name string `json:"name"` // The name of the option.
Options []CommandInteractionOption `json:"options,omitzero"` // For subcommands or grouped commands, the options passed to the subcommand or group. Mutually exclusive with value.
Type OptionType `json:"type"` // The type of option that was provided.
Focused bool `json:"focused"` // Whether this option is currently focused by the user during autocomplete. Is exclusively used for autocomplete interactions and will always be false otherwise.
}
A CommandInteractionOption represents data about a single option passed to a command.
type CommandOption ¶
type CommandOption struct {
MinValue *float64 `json:"min_value,omitzero"`
NameLocalizations map[Language]string `json:"name_localizations,omitzero"`
MaxValue *float64 `json:"max_value,omitzero"`
DescriptionLocalizations map[Language]string `json:"description_localizations,omitzero"`
Description string `json:"description"`
Name string `json:"name"`
Options []CommandOption `json:"options,omitzero"`
ChannelTypes []ChannelType `json:"channel_types,omitzero"`
// A list of max 10 (discord supported) file type extensions that you want this component to accept.
//
// For example: .png, .jpg, .qt, .mp3, .wav
// It also supports 3 groups (by typing "image", "video" or "audio" as type, please do not hardcode these lists as they are subject to change):
//
// IMAGE_EXTENSIONS = ('.png', '.gif', '.jpg', '.jpeg', '.jfif', '.webp', '.avif')
//
// VIDEO_EXTENSIONS = ('.mp4', '.mov', '.qt', '.webm')
//
// AUDIO_EXTENSIONS = ('.mp3', '.m4a', '.wav', '.ogg', '.opus', '.flac')
//
// We recommend using the provided file groups. if you are specifying only extensions,
// you must include .jpg for image uploads, and both .mp4 and .mov for video uploads,
// due to mobile schenanigans
//
// This feature only checks the extension on the filename - it does not actually inspect
// the contents of the file. You still need to make sure that the file is valid.
FileTypes []string `json:"file_types,omitzero"`
Choices []CommandOptionChoice `json:"choices,omitzero"`
MinLength uint16 `json:"min_length,omitzero"`
MaxLength uint16 `json:"max_length,omitzero"`
Required bool `json:"required,omitzero"`
Type OptionType `json:"type"`
AutoComplete bool `json:"autocomplete,omitzero"` // Required to be = true if you want to catch it later in auto complete handler.
}
type CommandOptionChoice ¶ added in v1.3.0
type CommandOptionChoice struct {
Value any `json:"value"` // string, float64 (double or integer) or bool
NameLocalizations map[Language]string `json:"name_localizations,omitzero"` // https://docs.discord.com/developers/reference#locales
Name string `json:"name"`
}
type CommandType ¶
type CommandType uint8
const ( CHAT_INPUT_COMMAND_TYPE CommandType = iota + 1 // Slash command (default option) USER_COMMAND_TYPE // Mounted to user/member profile MESSAGE_COMMAND_TYPE // Mounted to text message PRIMARY_ENTRY_POINT_COMMAND_TYPE // An UI-based command that represents the primary way to invoke an app's Activity )
type ComponentInteraction ¶
type ComponentInteraction struct {
Data ComponentInteractionData `json:"data"`
Interaction
}
A ComponentInteraction represents an interaction received from a user interacting with a message component, such as a ButtonComponent or SelectComponent.
https://docs.discord.com/developers/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) AcknowledgeWithLinearUpdate ¶ added in v1.11.0
func (itx *ComponentInteraction) AcknowledgeWithLinearUpdate(content string) error
func (*ComponentInteraction) AcknowledgeWithMessage ¶
func (itx *ComponentInteraction) AcknowledgeWithMessage(reply ResponseMessageData, ephemeral bool) error
func (*ComponentInteraction) AcknowledgeWithModal ¶
func (itx *ComponentInteraction) AcknowledgeWithModal(modal ResponseModalData) error
func (*ComponentInteraction) AcknowledgeWithUpdate ¶ added in v1.11.0
func (itx *ComponentInteraction) AcknowledgeWithUpdate(reply ResponseMessageData) error
Acknowledges the interaction by updating the message on which the component was attached.
type ComponentInteractionData ¶
type ComponentInteractionData struct {
Resolved *InteractionDataResolved `json:"resolved,omitempty"`
// The CustomID of the Component having been interacted with.
CustomID string `json:"custom_id"`
Values []string `json:"values,omitzero"` // Values the user selected in a select menu component
Type ComponentType `json:"component_type"` // The type of the component having been interacted with.
}
type ComponentType ¶
type ComponentType uint8
https://docs.discord.com/developers/components/reference#component-object
const ( ACTION_ROW_COMPONENT_TYPE ComponentType = iota + 1 // Layout component for Messages BUTTON_COMPONENT_TYPE // Interactive component for Messages STRING_SELECT_COMPONENT_TYPE // Interactive component for Messages and Modals TEXT_INPUT_COMPONENT_TYPE // Interactive component for Modals USER_SELECT_COMPONENT_TYPE // Interactive component for Messages ROLE_SELECT_COMPONENT_TYPE // Interactive component for Messages MENTIONABLE_SELECT_COMPONENT_TYPE // Interactive component for Messages CHANNEL_SELECT_COMPONENT_TYPE // Interactive component for Messages SECTION_COMPONENT_TYPE // Layout component for Messages TEXT_DISPLAY_COMPONENT_TYPE // Content component for Messages THUMBNAIL_COMPONENT_TYPE // Content component for Messages MEDIA_GALLERY_COMPONENT_TYPE // Content component for Messages FILE_COMPONENT_TYPE // Content component for Messages SEPARATOR_COMPONENT_TYPE // Layout component for Messages CONTAINER_COMPONENT_TYPE // Layout component for Messages LABEL_COMPONENT_TYPE // Layout component for Modals FILE_UPLOAD_COMPONENT_TYPE // Layout component for Modals RADIO_GROUP_COMPONENT_TYPE // Interactive component for Modals CHECKBOX_GROUP_COMPONENT_TYPE // Interactive component for Modals CHECKBOX_COMPONENT_TYPE // Interactive component for Modals )
type ContainerChildComponent ¶ added in v1.5.0
type ContainerChildComponent interface {
AnyComponent
// contains filtered or unexported methods
}
ContainerChildComponent represents components that can be used as the child of a ContainerComponent.
Currently valid types: ActionRowComponent, TextDisplayComponent, SectionComponent, MediaGalleryComponent, SeparatorComponent and FileComponent.
https://docs.discord.com/developers/components/reference#container-container-child-components
type ContainerComponent ¶ added in v1.3.0
type ContainerComponent struct {
Components []ContainerChildComponent `json:"components,omitzero"` // Child components to nest within the container.
ID uint32 `json:"id,omitzero"`
AccentColor uint32 `json:"accent_color,omitzero"` // The accent color of the container, as an RGB value from 0x000000 to 0xFFFFFF. (Write as a hex literal for best results.)
Type ComponentType `json:"type"` // Always = CONTAINER_COMPONENT_TYPE (17)
Spoiler bool `json:"spoiler,omitzero"` // Whether to mark the container as a spoiler.
}
A ContainerComponent visually encapsulates one or more components inside a message, alongside an optional accent color bar.
They can only be used inside messages.
https://docs.discord.com/developers/components/reference#container-container-structure
func (*ContainerComponent) UnmarshalJSON ¶ added in v1.3.0
func (c *ContainerComponent) UnmarshalJSON(data []byte) error
type ContentComponent ¶ added in v1.3.0
type ContentComponent interface {
AnyComponent
// contains filtered or unexported methods
}
ContentComponent represents non-interactive visual components such as text, media, or files. These are used to display static content in sections or containers.
type CreateGuildEventData ¶ added in v1.5.0
type CreateGuildEventData struct {
JoinedAt *time.Time `json:"joined_at"`
Members []Member `json:"members"`
Channels []PartialChannel `json:"channels"`
Threads []PartialChannel `json:"threads"`
Guild
MemberCount uint32 `json:"member_count"`
Large bool `json:"large,omitzero"`
}
Represents the payload for the GUILD_CREATE gateway event. It embeds the base Guild object and adds fields unique to this event.
https://docs.discord.com/developers/events/gateway-events#guild-create
type DefaultValueOption ¶ added in v1.3.0
type DefaultValueOption struct {
Type DefaultValueType `json:"type"` // The type of value that the option represents. Should be consistent across all default value options.
ID Snowflake `json:"id"` // Snowflake ID of a user, role, or channel
}
https://docs.discord.com/developers/components/reference#user-select-select-default-value-structure
type DefaultValueType ¶ added in v1.3.0
type DefaultValueType string
https://docs.discord.com/developers/components/reference#user-select-select-default-value-structure
const ( USER_DEFAULT_VALUE DefaultValueType = "user" ROLE_DEFAULT_VALUE DefaultValueType = "role" CHANNEL_DEFAULT_VALUE DefaultValueType = "channel" )
type Embed ¶
type Embed struct {
Author *EmbedAuthor `json:"author,omitempty"`
Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"`
Image *EmbedImage `json:"image,omitempty"`
Video *EmbedVideo `json:"video,omitempty"`
Provider *EmbedProvider `json:"provider,omitempty"`
Timestamp *time.Time `json:"timestamp,omitempty"`
Title string `json:"title,omitempty"`
Type string `json:"type,omitempty"`
URL string `json:"url,omitempty"`
Description string `json:"description,omitempty"`
Fields []EmbedField `json:"fields,omitzero"`
Color uint32 `json:"color,omitzero"`
Flags EmbedFlags `json:"flags,omitzero"`
}
https://docs.discord.com/developers/resources/message#embed-object
type EmbedAuthor ¶
type EmbedAuthor struct {
Name string `json:"name"`
URL string `json:"url,omitempty"`
IconURL string `json:"icon_url,omitempty"`
ProxyIconURL string `json:"proxy_icon_url,omitempty"`
}
https://docs.discord.com/developers/resources/message#embed-object-embed-author-structure
type EmbedField ¶
type EmbedField struct {
Name string `json:"name"`
Value string `json:"value"`
Inline bool `json:"inline,omitzero"`
}
https://docs.discord.com/developers/resources/message#embed-object-embed-field-structure
type EmbedFlags ¶ added in v1.11.0
type EmbedFlags = BitSet
https://docs.discord.com/developers/resources/message#embed-object-embed-flags
const ( CONTAINS_EXPLICIT_CONTENT_EMBED_FLAG EmbedFlags = 1 << 4 IS_CONTENT_INVENTORY_ENTRY_EMBED_FLAG EmbedFlags = 1 << 5 CONTAINS_GORE_CONTENT_EMBED_FLAG EmbedFlags = 1 << 6 CONTAINS_SELF_HARM_CONTENT_EMBED_FLAG EmbedFlags = 1 << 7 )
type EmbedFooter ¶
type EmbedFooter struct {
}
https://docs.discord.com/developers/resources/message#embed-object-embed-footer-structure
type EmbedImage ¶
type EmbedImage struct {
URL string `json:"url"`
ProxyURL string `json:"proxy_url,omitempty"`
ContentType string `json:"content_type,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Description string `json:"description,omitempty"`
Flags EmbedMediaFlags `json:"flags,omitzero"`
Width uint32 `json:"width,omitzero"`
Height uint32 `json:"height,omitzero"`
PlaceholderVersion uint32 `json:"placeholder_version,omitzero"`
}
https://docs.discord.com/developers/resources/message#embed-object-embed-image-structure
type EmbedMediaFlags ¶ added in v1.11.0
type EmbedMediaFlags = BitSet
https://docs.discord.com/developers/resources/message#embed-object-embed-media-flags
const (
IS_ANIMATED_EMBED_MEDIA_FLAG EmbedMediaFlags = 1 << 5
)
type EmbedProvider ¶
https://docs.discord.com/developers/resources/message#embed-object-embed-provider-structure
type EmbedThumbnail ¶
type EmbedThumbnail struct {
URL string `json:"url"`
ProxyURL string `json:"proxy_url,omitempty"`
ContentType string `json:"content_type,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Description string `json:"description,omitempty"`
Flags EmbedMediaFlags `json:"flags,omitzero"`
Width uint32 `json:"width,omitzero"`
Height uint32 `json:"height,omitzero"`
PlaceholderVersion uint32 `json:"placeholder_version,omitzero"`
}
https://docs.discord.com/developers/resources/message#embed-object-embed-image-structure
type EmbedVideo ¶
type EmbedVideo struct {
URL string `json:"url,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
ContentType string `json:"content_type,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Description string `json:"description,omitempty"`
Flags EmbedMediaFlags `json:"flags,omitzero"`
Width uint32 `json:"width,omitzero"`
Height uint32 `json:"height,omitzero"`
PlaceholderVersion uint32 `json:"placeholder_version,omitzero"`
}
https://docs.discord.com/developers/resources/message#embed-object-embed-video-structure
type Emoji ¶
type Emoji struct {
User *User `json:"user,omitempty"`
Name string `json:"name,omitempty"` // Note: may be empty for deleted emojis.
Roles []Snowflake `json:"roles,omitzero"`
ID Snowflake `json:"id,omitzero"`
RequireColons bool `json:"require_colons"`
Managed bool `json:"managed"`
Animated bool `json:"animated"`
Available bool `json:"available"`
}
https://docs.discord.com/developers/resources/emoji#emoji-object
type Entitlement ¶ added in v1.3.0
type Entitlement struct {
StartsAt *time.Time `json:"starts_at"`
EndsAt *time.Time `json:"ends_at"`
ID Snowflake `json:"id"`
SkuID Snowflake `json:"sku_id"`
ApplicationID Snowflake `json:"application_id"`
UserID Snowflake `json:"user_id,omitzero"` // ID of the user that is granted access to the entitlement's sku
GuildID Snowflake `json:"guild_id,omitzero"`
Type EntitlementType `json:"type"`
Deleted bool `json:"deleted"` // Whether entitlement was deleted
Consumed bool `json:"consumed"` // Whether entitlement was already used
}
Entitlements in Discord represent that a user or guild has access to a premium offering in your application.
Refer to the Monetization Overview for more information on how to use Entitlements in your app.
https://docs.discord.com/developers/resources/entitlement#entitlement-object
type EntitlementOwnerType ¶ added in v1.11.0
type EntitlementOwnerType uint8
https://docs.discord.com/developers/resources/entitlement#create-test-entitlement-json-params
const ( GUILD_ENTITLEMENT_OWNER_TYPE EntitlementOwnerType = iota + 1 USER_ENTITLEMENT_OWNER_TYPE )
type EntitlementType ¶ added in v1.3.0
type EntitlementType uint8
https://docs.discord.com/developers/resources/entitlement#entitlement-object-entitlement-types
const ( PURCHASE_ENTITLEMENT_TYPE EntitlementType = iota + 1 PREMIUM_SUBSCRIPTION_ENTITLEMENT_TYPE DEVELOPER_GIFT_ENTITLEMENT_TYPE TEST_MODE_PURCHASE_ENTITLEMENT_TYPE FREE_PURCHASE_ENTITLEMENT_TYPE USER_GIFT_ENTITLEMENT_TYPE PREMIUM_PURCHASE_ENTITLEMENT_TYPE APPLICATION_SUBSCRIPTION_ENTITLEMENT_TYPE )
type EventName ¶ added in v1.4.0
type EventName string
https://docs.discord.com/developers/events/gateway-events#receive-events
const ( READY_EVENT EventName = "READY" RESUMED_EVENT EventName = "RESUMED" INTERACTION_CREATE_EVENT EventName = "INTERACTION_CREATE" MESSAGE_CREATE_EVENT EventName = "MESSAGE_CREATE" MESSAGE_UPDATE_EVENT EventName = "MESSAGE_UPDATE" MESSAGE_DELETE_EVENT EventName = "MESSAGE_DELETE" MESSAGE_DELETE_BULK_EVENT EventName = "MESSAGE_DELETE_BULK" GUILD_CREATE_EVENT EventName = "GUILD_CREATE" GUILD_DELETE_EVENT EventName = "GUILD_DELETE" ENTITLEMENT_CREATE_EVENT EventName = "ENTITLEMENT_CREATE" ENTITLEMENT_UPDATE_EVENT EventName = "ENTITLEMENT_UPDATE" ENTITLEMENT_DELETE_EVENT EventName = "ENTITLEMENT_DELETE" INTEGRATION_CREATE_EVENT EventName = "INTEGRATION_CREATE" INTEGRATION_UPDATE_EVENT EventName = "INTEGRATION_UPDATE" INTEGRATION_DELETE_EVENT EventName = "INTEGRATION_DELETE" VOICE_STATE_UPDATE_EVENT EventName = "VOICE_STATE_UPDATE" )
type EventPacket ¶ added in v1.4.0
type EventPacket struct {
Event EventName `json:"t,omitempty"`
Data jsontext.Value `json:"d"`
Sequence uint32 `json:"s,omitzero"`
Opcode Opcode `json:"op"`
}
In modern discord docs - otherwise known as generic gateway event.
https://docs.discord.com/developers/events/gateway#gateway-events
type ExplicitContentFilter ¶ added in v1.3.5
type ExplicitContentFilter uint8
https://docs.discord.com/developers/resources/guild#guild-object-explicit-content-filter-level
const ( DISABLED_CONTENT_FILTER ExplicitContentFilter = iota MEMBERS_WITHOUT_ROLES_CONTENT_FILTER ALL_MEMBERS_CONTENT_FILTER )
type FileComponent ¶ added in v1.3.0
type FileComponent struct {
Name string `json:"name,omitempty"` // This field is ignored and provided by the API as part of the response.
File UnfurledMediaItem `json:"file"` // This unfurled media item is unique in that it only supports attachment references using the attachment://<filename> syntax.
ID uint32 `json:"id,omitzero"`
Size uint32 `json:"size,omitzero"` // The size of the file in bytes. This field is ignored and provided by the API as part of the response.
Type ComponentType `json:"type"` // Always = FILE_COMPONENT_TYPE (13)
Spoiler bool `json:"spoiler,omitzero"`
}
https://docs.discord.com/developers/components/reference#file-file-structure
type FileUploadComponent ¶ added in v1.6.0
type FileUploadComponent struct {
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id,omitempty"`
// A list of max 10 (discord supported) file type extensions that you want this component to accept.
//
// For example: .png, .jpg, .qt, .mp3, .wav
// It also supports 3 groups (by typing "image", "video" or "audio" as type, please do not hardcode these lists as they are subject to change):
//
// IMAGE_EXTENSIONS = ('.png', '.gif', '.jpg', '.jpeg', '.jfif', '.webp', '.avif')
//
// VIDEO_EXTENSIONS = ('.mp4', '.mov', '.qt', '.webm')
//
// AUDIO_EXTENSIONS = ('.mp3', '.m4a', '.wav', '.ogg', '.opus', '.flac')
//
// We recommend using the provided file groups. if you are specifying only extensions,
// you must include .jpg for image uploads, and both .mp4 and .mov for video uploads,
// due to mobile schenanigans
//
// This feature only checks the extension on the filename - it does not actually inspect
// the contents of the file. You still need to make sure that the file is valid.
FileTypes []string `json:"file_types,omitzero"`
Values []Snowflake `json:"values,omitzero"` // IDs of the uploaded files found in the resolved data. Populated on modal submission.
ID uint32 `json:"id,omitzero"` // Optional identifier for component
Type ComponentType `json:"type"` // Always = FILE_UPLOAD_COMPONENT_TYPE (19)
MinValues uint8 `json:"min_values,omitzero"` // The minimum number of files that must be uploaded; defaults to 1 and must be between 0 and 10. Can only be 0 if required is set to false.
MaxValues uint8 `json:"max_values,omitzero"` // The maximum number of files that can be uploaded; defaults to 1 and must be between 1 and 10.
Required bool `json:"required"` // Whether a file upload is required to submit the modal.
}
A FileUploadComponent allows users to upload one or more files in modals. The maximum file size a user can upload is based solely on the user’s upload limit in that channel.
They can only be used inside [LabelComponent]s within modals.
https://docs.discord.com/developers/components/reference#file-upload-file-upload-structure
type GatewayBot ¶ added in v1.4.0
type GatewayBot struct {
URL string `json:"url"`
ShardCount uint16 `json:"shards"`
SessionStartLimit SessionStartLimit `json:"session_start_limit"`
}
https://docs.discord.com/developers/events/gateway#get-gateway-bot
type GatewayClient ¶ added in v1.4.0
type GatewayClient struct {
*BaseClient
Gateway *ShardManager
// contains filtered or unexported fields
}
func NewGatewayClient ¶ added in v1.4.0
func NewGatewayClient(opt GatewayClientOptions) *GatewayClient
type GatewayClientOptions ¶ added in v1.4.0
type GatewayClientOptions struct {
CustomEventHandler func(shardID uint16, packet EventPacket)
BaseClientOptions
Trace bool // Whether to enable detailed logging for shard manager and basic client actions.
// Compression enables zstd-stream compression for gateway traffic. It is
// disabled by default. The decoder sizes its window from the zstd frame
// header and is reused across reconnects.
Compression bool
// Deprecated: use Compression instead. It enables zstd-stream compression
// when true.
ZlibCompression bool
}
type Guild ¶ added in v1.3.5
type Guild struct {
PrefferedLocale string `json:"preferred_locale,omitempty"`
Name string `json:"name"`
IconHash string `json:"icon,omitempty"` // Hash code used to access guild's icon. Call Guild.IconURL to get direct url.
VanityURL string `json:"vanity_url_code,omitempty"`
DiscoverySplashHash string `json:"discovery_splash,omitempty"` // Hash code used to access guild's special discovery splash background (only available for "DISCOVERABLE" guilds). Call Guild.DiscoverySplashURL to get direct url.
Description string `json:"description,omitempty"`
SplashHash string `json:"splash,omitempty"` // Hash code used to access guild's splash background. Call Guild.SplashURL to get direct url.
BannerHash string `json:"banner,omitempty"` // Hash code used to access guild's icon. Call Guild.BannerURL to get direct url.
Emojis []Emoji `json:"emojis,omitzero"`
Roles []Role `json:"roles,omitzero"`
Features []string `json:"features,omitzero"` // https://docs.discord.com/developers/resources/guild#guild-object-guild-features
ID Snowflake `json:"id"`
AFKChannelID Snowflake `json:"afk_channel_id,omitzero"`
OwnerID Snowflake `json:"owner_id"`
RulesChannelID Snowflake `json:"rules_channel_id,omitzero"`
WidgetChannelID Snowflake `json:"widget_channel_id,omitzero"` // The channel ID that the widget will generate an invite to, or null if set to no invite.
ApplicationID Snowflake `json:"application_id,omitzero"` // Application id of the guild creator if it is bot-created (never seen it in use).
SystemChannelID Snowflake `json:"system_channel_id,omitzero"`
PublicUpdatesChannelID Snowflake `json:"public_updates_channel_id,omitzero"`
SafetyAlertsChannelID Snowflake `json:"safety_alerts_channel_id,omitzero"`
SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"`
AFKChannelTimeout uint32 `json:"afk_timeout"` // AFK timeout value in seconds.
MaxPresences uint32 `json:"max_presences,omitzero"` // The maximum number of presences for the guild (null is always returned, apart from the largest of guilds).
MaxMembers uint32 `json:"max_members,omitzero"`
MaxVideoChannelUsers uint32 `json:"max_video_channel_users,omitzero"`
MaxStageVideoChannelUsers uint32 `json:"max_stage_video_channel_users,omitzero"`
PremiumSubscriptionCount uint32 `json:"premium_subscription_count,omitzero"` // The number of boosts this guild currently has.
ApproximateMemberCount uint32 `json:"approximate_member_count,omitzero"`
ApproximatePresenceCount uint32 `json:"approximate_presence_count,omitzero"`
MFALevel MFALevel `json:"mfa_level"`
ExplicitContentFilter ExplicitContentFilter `json:"explicit_content_filter"`
DefaultMessageNotifications MessageNotificationLevel `json:"default_message_notifications"`
NSFWLevel NSFWLevel `json:"nsfw_level"`
VerificationLevel VerificationLevel `json:"verification_level"`
PremiumTier PremiumTier `json:"premium_tier"`
WidgetEnabled bool `json:"widget_enabled"` // Whether server uses widget.
PremiumProgressBarEnabled bool `json:"premium_progress_bar_enabled"`
}
https://docs.discord.com/developers/resources/guild#guild-object
func (*Guild) BannerURL ¶ added in v1.3.5
Returns a direct url to guild banner. It'll return empty string if there's no custom banner.
func (*Guild) DiscoverySplashURL ¶ added in v1.3.5
Returns a direct url to guild discovery splash background. It'll return empty string if there's no discovery splash bg.
type HTTPClient ¶ added in v1.4.0
type HTTPClient struct {
*BaseClient
PublicKey ed25519.PublicKey
// contains filtered or unexported fields
}
func NewHTTPClient ¶ added in v1.4.0
func NewHTTPClient(opt HTTPClientOptions) *HTTPClient
func (*HTTPClient) DiscordRequestHandler ¶ added in v1.4.0
func (client *HTTPClient) DiscordRequestHandler(w http.ResponseWriter, r *http.Request)
This handler already runs in dedicated goroutine (from std http server behavior). Due to default HTTP server behavior, this goroutine cannot block for more than 3s, to achieve that we use client interaction responder trick.
type HTTPClientOptions ¶ added in v1.4.0
type HTTPClientOptions struct {
PublicKey string
BaseClientOptions
Trace bool // Whether to enable basic logging for the client actions.
}
type HeartbeatEvent ¶ added in v1.4.0
https://docs.discord.com/developers/events/gateway-events#heartbeat
type HelloEventData ¶ added in v1.4.0
type HelloEventData struct {
HeartbeatInterval uint32 `json:"heartbeat_interval"`
}
https://docs.discord.com/developers/events/gateway-events#hello
type IdentifyEvent ¶ added in v1.4.0
type IdentifyEvent struct {
Data IdentifyPayloadData `json:"d"`
Opcode Opcode `json:"op"`
}
https://docs.discord.com/developers/events/gateway-events#identify
type IdentifyPayloadData ¶ added in v1.4.0
type IdentifyPayloadData struct {
Presence *UpdatePresenceEventData `json:"presence,omitempty"`
Properties IdentifyPayloadDataProperties `json:"properties"`
Token string `json:"token"`
Intents uint32 `json:"intents"`
ShardOrder [2]uint16 `json:"shard"` // [currentID, maxCount]
LargeThreshold uint8 `json:"large_threshold"` // 50 - 250
}
https://docs.discord.com/developers/events/gateway-events#identify-identify-structure
type IdentifyPayloadDataProperties ¶ added in v1.4.0
type IdentifyPayloadDataProperties struct {
OS string `json:"os"`
Browser string `json:"browser"`
Device string `json:"device"`
}
https://docs.discord.com/developers/events/gateway-events#identify-identify-connection-properties
type Interaction ¶ added in v1.3.0
type Interaction struct {
Member *Member `json:"member,omitempty"`
GatewayClient *GatewayClient `json:"-"` // Only provided if using Gateway Client.
HTTPClient *HTTPClient `json:"-"` // Only provided if using HTTP Client.
BaseClient *BaseClient `json:"-"` // Always provided.
User *User `json:"user,omitempty"`
Locale Language `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.
Token string `json:"token"` // Temporary token used for responding to the interaction. It's not the same as bot token.
Data jsontext.Value `json:"data"`
AuthorizingIntegrationOwners map[ApplicationIntegrationType]Snowflake `json:"authorizing_integration_owners,omitzero"` // Mapping of installation contexts that the interaction was authorized for to related user or guild IDs.
Entitlements []Entitlement `json:"entitlements,omitzero"` // For monetized apps, any entitlements for the invoking user, representing access to premium SKUs.
GuildID Snowflake `json:"guild_id,omitzero"`
ID Snowflake `json:"id"`
ChannelID Snowflake `json:"channel_id,omitzero"`
PermissionFlags PermissionFlags `json:"app_permissions,string"` // Bitwise set of permissions the app/bot has within the channel the interaction was sent from (guild text channel or DM channel).
ApplicationID Snowflake `json:"application_id"`
AttachmentSizeLimit uint64 `json:"attachment_size_limit,omitzero"` // Attachment size limit in bytes.
Context InteractionContextType `json:"context,omitzero"` // Context where the interaction was triggered from.
ShardID uint16 `json:"-"` // Only provided if using Gateway Client. Shard ID = 0 is also a valid ID.
Type InteractionType `json:"type"`
// contains filtered or unexported fields
}
Represents general interaction. Use Command/Component/Modal interaction to read Data field.
func (*Interaction) BaseUser ¶ added in v1.4.2
func (itx *Interaction) BaseUser() *User
Returns user data either from member or from user (depending if interaction was used in a server).
func (*Interaction) Responded ¶ added in v1.5.0
func (itx *Interaction) Responded() bool
Returns whether this interaction already was responded to.
type InteractionContextType ¶ added in v1.2.3
type InteractionContextType uint16 // use uint16 instead uint8 to avoid Go's json marshal logic that thinks of it as symbols.
const ( GUILD_CONTEXT_TYPE InteractionContextType = iota BOT_DM_CONTEXT_TYPE PRIVATE_CHANNEL_CONTEXT_TYPE )
type InteractionDataResolved ¶
type InteractionDataResolved struct {
Users map[Snowflake]User `json:"users,omitzero"`
Members map[Snowflake]Member `json:"members,omitzero"`
Roles map[Snowflake]Role `json:"roles,omitzero"`
Channels map[Snowflake]PartialChannel `json:"channels,omitzero"`
Messages map[Snowflake]Message `json:"messages,omitzero"`
Attachments map[Snowflake]Attachment `json:"attachments,omitzero"`
}
func (*InteractionDataResolved) ResolveAttachment ¶ added in v1.11.0
func (r *InteractionDataResolved) ResolveAttachment(id Snowflake) Attachment
Returns pointer to attachment if present in resolved data. It'll return empty struct if there's no resolved attachment.
func (*InteractionDataResolved) ResolveChannel ¶ added in v1.11.0
func (r *InteractionDataResolved) ResolveChannel(id Snowflake) PartialChannel
Returns pointer to partial channel if present in resolved data. It'll return empty struct if there's no resolved partial channel.
func (*InteractionDataResolved) ResolveMember ¶ added in v1.11.0
func (r *InteractionDataResolved) ResolveMember(id Snowflake) Member
Returns pointer to member if present in resolved data and binds member.user. It'll return empty struct if there's no resolved member.
func (*InteractionDataResolved) ResolveMessage ¶ added in v1.11.0
func (r *InteractionDataResolved) ResolveMessage(id Snowflake) Message
Returns pointer to message if present in resolved data. It'll return empty struct if there's no resolved message.
func (*InteractionDataResolved) ResolveRole ¶ added in v1.11.0
func (r *InteractionDataResolved) ResolveRole(id Snowflake) (Role, bool)
Returns pointer to guild role if present in resolved data. It'll return empty struct if there's no resolved role.
func (*InteractionDataResolved) ResolveUser ¶ added in v1.11.0
func (r *InteractionDataResolved) ResolveUser(id Snowflake) User
Returns pointer to user if present in resolved data. It'll return empty struct if there's no resolved user.
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 InteractiveComponent ¶ added in v1.3.0
type InteractiveComponent interface {
AnyComponent
// contains filtered or unexported methods
}
InteractiveComponent is a component that can trigger interactions, like buttons or select menus. These can be placed inside Action Rows or used as accessories in sections. Use when you need a component that triggers a callback or response.
type LabelChildComponent ¶ added in v1.3.2
type LabelChildComponent interface {
AnyComponent
// contains filtered or unexported methods
}
LabelChildComponent represents components that can be used as the child of a LabelComponent. Only one child component is allowed per label.
Currently valid types: TextInputComponent, StringSelectComponent, SelectComponent (user/role/mentionable/channel selects), FileUploadComponent, RadioGroupComponent, CheckboxGroupComponent and CheckboxComponent.
https://docs.discord.com/developers/components/reference#label-label-child-components
type LabelComponent ¶ added in v1.3.2
type LabelComponent struct {
Component LabelChildComponent `json:"component"` // The component nested within the label.
Label string `json:"label"` // The header text to show on the label; max 45 characters.
Description string `json:"description,omitempty"` // An additional description for the label; max 100 characters.
ID uint32 `json:"id,omitzero"` // Optional identifier for component
Type ComponentType `json:"type"` // Always = LABEL_COMPONENT_TYPE (18)
}
A LabelComponent wraps a child component with text and an optional description.
They can only be used inside modals.
https://docs.discord.com/developers/components/reference#label-label-structure
func (*LabelComponent) UnmarshalJSON ¶ added in v1.3.2
func (c *LabelComponent) UnmarshalJSON(data []byte) error
type Language ¶
type Language string
https://docs.discord.com/developers/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" CZECH_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 LayoutComponent ¶ added in v1.3.0
type LayoutComponent interface {
AnyComponent
// contains filtered or unexported methods
}
LayoutComponent represents message layout containers like Action Rows, Sections, Separators & Containers.
These are used to control the final look of your custom message/modal.
type MFALevel ¶ added in v1.3.5
type MFALevel uint8
https://docs.discord.com/developers/resources/guild#guild-object-mfa-level
type MediaGalleryComponent ¶ added in v1.3.0
type MediaGalleryComponent struct {
Items []MediaGalleryItem `json:"items,omitzero"` // 1 to 10 media gallery items
ID uint32 `json:"id,omitzero"`
Type ComponentType `json:"type"` // Always = MEDIA_GALLERY_COMPONENT_TYPE (12)
}
https://docs.discord.com/developers/components/reference#media-gallery-media-gallery-structure
type MediaGalleryItem ¶ added in v1.3.0
type MediaGalleryItem struct {
Description string `json:"description,omitempty"` // Alt text for the media, max 1024 characters
Media UnfurledMediaItem `json:"media"`
Spoiler bool `json:"spoiler,omitzero"`
}
https://docs.discord.com/developers/components/reference#media-gallery-media-gallery-item-structure
type Member ¶
type Member struct {
JoinedAt time.Time `json:"joined_at"`
AvatarDecorationData *AvatarDecoration `json:"avatar_decoration_data,omitempty"`
CommunicationDisabledUntil *time.Time `json:"communication_disabled_until,omitempty"`
User *User `json:"user,omitempty"`
PremiumSince *time.Time `json:"premium_since,omitempty"`
GuildBannerHash string `json:"banner,omitempty"` // Hash code used to access member's custom, guild banner. Call Member.GuildBannerURL to get direct url.
GuildAvatarHash string `json:"avatar,omitempty"` // Hash code used to access member's custom, guild avatar. Call Member.GuildAvatarURL to get direct url.
Nickname string `json:"nick,omitempty"`
RoleIDs []Snowflake `json:"roles"`
Flags MemberFlags `json:"flags"`
PermissionFlags PermissionFlags `json:"permissions,string"`
// It's not part of Member API data struct but tempest Client should always attach it for conveniency.
GuildID Snowflake `json:"-"`
Deaf bool `json:"deaf"`
Mute bool `json:"mute"`
Pending bool `json:"pending"`
}
https://docs.discord.com/developers/resources/guild#guild-member-object
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.
func (*Member) GuildBannerURL ¶ added in v1.2.3
Returns a direct url to members's guild specific banner. It'll return empty string if targeted member don't use custom banner for that server.
type MemberFlags ¶ added in v1.2.3
type MemberFlags = BitSet
https://docs.discord.com/developers/resources/guild#guild-member-object-guild-member-flags
const ( DID_REJOIN_MEMBER_FLAG MemberFlags = 1 << iota COMPLETED_ONBOARDING_MEMBER_FLAG BYPASSES_VERIFICATION_MEMBER_FLAG STARTED_ONBOARDING_MEMBER_FLAG IS_GUEST_MEMBER_FLAG STARTED_HOME_ACTIONS_MEMBER_FLAG COMPLETED_HOME_ACTIONS_MEMBER_FLAG AUTOMOD_QUARANTINED_USERNAME_MEMBER_FLAG DM_SETTINGS_UPSELL_ACKNOWLEDGED_MEMBER_FLAG AUTOMOD_QUARANTINED_GUILD_TAG_MEMBER_FLAG )
type Message ¶
type Message struct {
MessageReference *MessageReference `json:"message_reference,omitempty"`
InteractionMetadata *MessageInteractionMetadata `json:"interaction_metadata,omitempty"`
Poll *Poll `json:"poll,omitempty"`
Member *Member `json:"member,omitempty"`
Resolved *InteractionDataResolved `json:"resolved,omitempty"`
Author *User `json:"author,omitempty"` // The author of this message.
Timestamp *time.Time `json:"timestamp"`
EditedTimestamp *time.Time `json:"edited_timestamp,omitempty"`
ReferencedMessage *Message `json:"referenced_message,omitempty"`
Content string `json:"content,omitempty"` // The message's content.
Nonce Nonce `json:"nonce,omitempty"` // Used for validating a message was sent.
Attachments []Attachment `json:"attachments"`
Mentions []User `json:"mentions"` // All users specifically mentioned in the message.
MentionRoles []Snowflake `json:"mention_roles"`
MentionChannels []ChannelMention `json:"mention_channels,omitzero"`
Embeds []Embed `json:"embeds"`
StickerItems []StickerItem `json:"sticker_items,omitzero"`
Reactions []Reaction `json:"reactions,omitzero"`
Components []MessageComponent `json:"components,omitzero"` // All components included in the message.
WebhookID Snowflake `json:"webhook_id,omitzero"`
ApplicationID Snowflake `json:"application_id,omitzero"`
GuildID Snowflake `json:"guild_id,omitzero"`
Flags MessageFlags `json:"flags,omitzero"`
ChannelID Snowflake `json:"channel_id"`
ID Snowflake `json:"id"`
Position uint32 `json:"position,omitzero"`
Type MessageType `json:"type,omitzero"`
MentionEveryone bool `json:"mention_everyone"` // Whether this message mentions everyone.
TTS bool `json:"tts"` // Whether this was a TTS message.
Pinned bool `json:"pinned"`
}
https://docs.discord.com/developers/resources/message#message-object
func (*Message) UnmarshalJSON ¶ added in v1.3.0
type MessageComponent ¶ added in v1.5.0
type MessageComponent interface {
AnyComponent
// contains filtered or unexported methods
}
MessageComponent represents components that can be used inside the top level of messages, such as ActionRowComponent and [SectionComponent]s.
A list of all valid types can be found on Discord's website, though this interface intentionally excludes certain components that cannot appear by themselves (such as [SelectComponent]s).
type MessageFlags ¶ added in v1.2.3
type MessageFlags = BitSet
https://docs.discord.com/developers/resources/message#message-object-message-flags
const ( CROSSPOSTED_MESSAGE_FLAG MessageFlags = 1 << iota IS_CROSSPOST_MESSAGE_FLAG SUPPRESS_EMBEDS_MESSAGE_FLAG SOURCE_MESSAGE_DELETED_MESSAGE_FLAG URGENT_MESSAGE_FLAG HAS_THREAD_MESSAGE_FLAG EPHEMERAL_MESSAGE_FLAG LOADING_MESSAGE_FLAG FAILED_TO_MENTION_SOME_ROLES_IN_THREAD_MESSAGE_FLAG SUPPRESS_NOTIFICATIONS_MESSAGE_FLAG IS_VOICE_MESSAGE_MESSAGE_FLAG HAS_SNAPSHOT_MESSAGE_FLAG IS_COMPONENTS_V2_MESSAGE_FLAG // When used, regular content, embeds, poll & stickers fields will be ignored. )
type MessageInteractionMetadata ¶ added in v1.4.2
type MessageInteractionMetadata struct {
TargetUser *User `json:"target_user,omitempty"`
User User `json:"user"`
ID Snowflake `json:"id"`
TargetMessageID Snowflake `json:"target_message_id,omitzero"`
Type InteractionType `json:"type"`
}
type MessageNotificationLevel ¶ added in v1.3.5
type MessageNotificationLevel uint8
https://docs.discord.com/developers/resources/guild#guild-object-default-message-notification-level
const ( ALL_MESSAGES_NOTIFICATION_LEVEL MessageNotificationLevel = iota ONLY_MENTIONS_NOTIFICATION_LEVEL )
type MessageReference ¶
type MessageReference struct {
MessageID Snowflake `json:"message_id,omitzero"`
ChannelID Snowflake `json:"channel_id,omitzero"`
GuildID Snowflake `json:"guild_id,omitzero"`
Type MessageReferenceType `json:"type,omitzero"`
FailIfNotExists bool `json:"fail_if_not_exists"`
}
https://docs.discord.com/developers/resources/message#message-reference-structure
type MessageReferenceType ¶ added in v1.6.0
type MessageReferenceType uint8
https://docs.discord.com/developers/resources/message#message-reference-types
const ( DEFAULT_MESSAGE_REFERENCE_TYPE MessageReferenceType = iota // A standard reference used by replies. Coupled with: referenced_message FORWARD_MESSAGE_REFERENCE_TYPE // Reference used to point to a message at a point in time. Coupled with: message_snapshot )
type MessageType ¶ added in v1.11.0
type MessageType uint8
https://docs.discord.com/developers/resources/message#message-object-message-types
const ( DEFAULT_MESSAGE_TYPE MessageType = iota RECIPIENT_ADD_MESSAGE_TYPE RECIPIENT_REMOVE_MESSAGE_TYPE CALL_MESSAGE_TYPE CHANNEL_NAME_CHANGE_MESSAGE_TYPE CHANNEL_ICON_CHANGE_MESSAGE_TYPE CHANNEL_PINNED_MESSAGE_TYPE USER_JOIN_MESSAGE_TYPE GUILD_BOOST_MESSAGE_TYPE GUILD_BOOST_TIER_1_MESSAGE_TYPE GUILD_BOOST_TIER_2_MESSAGE_TYPE GUILD_BOOST_TIER_3_MESSAGE_TYPE CHANNEL_FOLLOW_ADD_MESSAGE_TYPE GUILD_DISCOVERY_DISQUALIFIED_MESSAGE_TYPE GUILD_DISCOVERY_REQUALIFIED_MESSAGE_TYPE GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING_MESSAGE_TYPE GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING_MESSAGE_TYPE THREAD_CREATED_MESSAGE_TYPE REPLY_MESSAGE_TYPE CHAT_INPUT_COMMAND_MESSAGE_TYPE THREAD_STARTER_MESSAGE_TYPE GUILD_INVITE_REMINDER_MESSAGE_TYPE CONTEXT_MENU_COMMAND_MESSAGE_TYPE AUTO_MODERATION_ACTION_MESSAGE_TYPE ROLE_SUBSCRIPTION_PURCHASE_MESSAGE_TYPE INTERACTION_PREMIUM_UPSELL_MESSAGE_TYPE STAGE_START_MESSAGE_TYPE STAGE_END_MESSAGE_TYPE STAGE_SPEAKER_MESSAGE_TYPE STAGE_TOPIC_MESSAGE_TYPE GUILD_APPLICATION_PREMIUM_SUBSCRIPTION_MESSAGE_TYPE GUILD_INCIDENT_ALERT_MODE_ENABLED_MESSAGE_TYPE GUILD_INCIDENT_ALERT_MODE_DISABLED_MESSAGE_TYPE GUILD_INCIDENT_REPORT_RAID_MESSAGE_TYPE GUILD_INCIDENT_REPORT_FALSE_ALARM_MESSAGE_TYPE PURCHASE_NOTIFICATION_MESSAGE_TYPE POLL_RESULT_MESSAGE_TYPE )
type ModalComponent ¶ added in v1.5.0
type ModalComponent interface {
AnyComponent
// contains filtered or unexported methods
}
ModalComponent represents components that can be used inside the top level of modals, such as [TextDisplayComponent]s and [LabelComponent]s.
A list of all valid types can be found on Discord's website, though this interface intentionally excludes certain components that cannot appear by themselves (such as [SelectComponent]s).
type ModalInteraction ¶
type ModalInteraction struct {
Data ModalInteractionData `json:"data"`
Interaction
}
A ModalInteraction represents an interaction received from a user submitting a modal.
https://docs.discord.com/developers/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) AcknowledgeWithLinearUpdate ¶ added in v1.11.0
func (itx *ModalInteraction) AcknowledgeWithLinearUpdate(content string) 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) AcknowledgeWithUpdate ¶ added in v1.11.0
func (itx *ModalInteraction) AcknowledgeWithUpdate(response ResponseMessageData) error
Acknowledges the interaction by updating the message on which the component was attached.
func (*ModalInteraction) Defer ¶ added in v1.3.2
func (itx *ModalInteraction) Defer(ephemeral bool) error
Used to let user/member know that the bot is processing the modal submission, which will close the modal dialog. Set ephemeral = true to make notification visible only to the submitter.
func (*ModalInteraction) GetCheckboxGroupValues ¶ added in v1.11.0
func (itx *ModalInteraction) GetCheckboxGroupValues(customID string) []string
Retrieves the selected values of the first CheckboxGroupComponent inside the modal (at any depth) with the given customID.
If no such component exists, nil is returned instead.
func (*ModalInteraction) GetCheckboxValue ¶ added in v1.11.0
func (itx *ModalInteraction) GetCheckboxValue(customID string) (bool, bool)
Retrieves the state of the first CheckboxComponent inside the modal (at any depth) with the given customID. The second return value indicates whether the component was found.
func (*ModalInteraction) GetFileUploadAttachments ¶ added in v1.11.0
func (itx *ModalInteraction) GetFileUploadAttachments(customID string) []Attachment
Retrieves the resolved Attachment objects of the first FileUploadComponent inside the modal (at any depth) with the given customID.
If no such component exists or no attachments were resolved, nil is returned instead.
func (*ModalInteraction) GetFileUploadValues ¶ added in v1.11.0
func (itx *ModalInteraction) GetFileUploadValues(customID string) []Snowflake
Retrieves the uploaded file attachment IDs of the first FileUploadComponent inside the modal (at any depth) with the given customID.
If no such component exists, nil is returned instead.
func (*ModalInteraction) GetInputValue ¶
func (itx *ModalInteraction) GetInputValue(customID string) string
Retrieves the contents of the first TextInputComponent inside the modal (at any depth) with the given customID.
If no such component exists, an empty string is returned instead.
func (*ModalInteraction) GetRadioGroupValue ¶ added in v1.11.0
func (itx *ModalInteraction) GetRadioGroupValue(customID string) (string, bool)
Retrieves the selected value of the first RadioGroupComponent inside the modal (at any depth) with the given customID. The second return value indicates whether a value was selected.
func (*ModalInteraction) GetSelectValues ¶ added in v1.11.0
func (itx *ModalInteraction) GetSelectValues(customID string) []Snowflake
Retrieves the selected snowflake IDs of the first SelectComponent (user, role, mentionable, or channel select) inside the modal (at any depth) with the given customID.
If no such component exists, nil is returned instead.
func (*ModalInteraction) GetStringSelectValues ¶ added in v1.11.0
func (itx *ModalInteraction) GetStringSelectValues(customID string) []string
Retrieves the selected values of the first StringSelectComponent inside the modal (at any depth) with the given customID.
If no such component exists, nil is returned instead.
func (*ModalInteraction) SendFollowUp ¶ added in v1.3.2
func (itx *ModalInteraction) SendFollowUp(content ResponseMessageData, ephemeral bool) (Message, error)
Used after defering a modal submission to send a message to the user/member. Set ephemeral = true to make message visible only to the submitter.
func (*ModalInteraction) SendLinearFollowUp ¶ added in v1.3.2
func (itx *ModalInteraction) SendLinearFollowUp(content string, ephemeral bool) (Message, error)
Used after defering a modal submission to send a message to the user/member. Set ephemeral = true to make message visible only to the submitter.
type ModalInteractionData ¶
type ModalInteractionData struct {
Resolved *InteractionDataResolved `json:"resolved,omitempty"`
// The CustomID of the modal having been submitted.
CustomID string `json:"custom_id"`
Components []ModalComponent `json:"components,omitzero"` // The components that were sent inside the modal, having been filled with user input.
}
ModalInteractionData represents the data received from a user submitting a modal.
func (*ModalInteractionData) UnmarshalJSON ¶ added in v1.3.0
func (msd *ModalInteractionData) UnmarshalJSON(data []byte) error
type NSFWLevel ¶ added in v1.11.0
type NSFWLevel uint8
https://docs.discord.com/developers/resources/guild#guild-object-guild-nsfw-level
type NitroType ¶
type NitroType uint8
https://docs.discord.com/developers/resources/user#user-object-premium-types
type Nonce ¶ added in v1.11.0
type Nonce string
Nonce is a message nonce. Discord sends it as either a string or an integer, so it is normalized to a string when decoding.
https://docs.discord.com/developers/resources/message#message-object
func (*Nonce) UnmarshalJSON ¶ added in v1.11.0
type Opcode ¶ added in v1.4.0
type Opcode uint8
https://docs.discord.com/developers/topics/opcodes-and-status-codes#gateway-gateway-opcodes
type OptionType ¶
type OptionType uint8
const ( SUB_COMMAND_OPTION_TYPE OptionType = iota + 1 SUB_COMMAND_GROUP_OPTION_TYPE // NOT OFFICIALLY SUPPORTED BY LIBRARY 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 {
Name string `json:"name"`
ID Snowflake `json:"id"`
PermissionFlags PermissionFlags `json:"permissions,string"`
Type ChannelType `json:"type"`
}
https://docs.discord.com/developers/resources/channel#channel-object
type PermissionFlags ¶ added in v1.2.3
type PermissionFlags = BitSet
https://docs.discord.com/developers/topics/permissions#permissions-bitwise-permission-flags
const ( CREATE_INSTANT_INVITE_PERMISSION_FLAG PermissionFlags = 1 << iota KICK_MEMBERS_PERMISSION_FLAG BAN_MEMBERS_PERMISSION_FLAG ADMINISTRATOR_PERMISSION_FLAG MANAGE_CHANNELS_PERMISSION_FLAG MANAGE_GUILD_PERMISSION_FLAG ADD_REACTIONS_PERMISSION_FLAG VIEW_AUDIT_LOG_PERMISSION_FLAG PRIORITY_SPEAKER_PERMISSION_FLAG STREAM_PERMISSION_FLAG VIEW_CHANNEL_PERMISSION_FLAG SEND_MESSAGES_PERMISSION_FLAG SEND_TTS_MESSAGES_PERMISSION_FLAG MANAGE_MESSAGES_PERMISSION_FLAG EMBED_LINKS_PERMISSION_FLAG ATTACH_FILES_PERMISSION_FLAG READ_MESSAGE_HISTORY_PERMISSION_FLAG MENTION_EVERYONE_PERMISSION_FLAG USE_EXTERNAL_EMOJIS_PERMISSION_FLAG VIEW_GUILD_INSIGHTS_PERMISSION_FLAG CONNECT_PERMISSION_FLAG SPEAK_PERMISSION_FLAG MUTE_MEMBERS_PERMISSION_FLAG DEAFEN_MEMBERS_PERMISSION_FLAG MOVE_MEMBERS_PERMISSION_FLAG USE_VAD_PERMISSION_FLAG CHANGE_NICKNAME_PERMISSION_FLAG MANAGE_NICKNAMES_PERMISSION_FLAG MANAGE_ROLES_PERMISSION_FLAG MANAGE_WEBHOOKS_PERMISSION_FLAG MANAGE_GUILD_EXPRESSIONS_PERMISSION_FLAG USE_APPLICATION_COMMANDS_PERMISSION_FLAG REQUEST_TO_SPEAK_PERMISSION_FLAG MANAGE_EVENTS_PERMISSION_FLAG MANAGE_THREADS_PERMISSION_FLAG CREATE_PUBLIC_THREADS_PERMISSION_FLAG CREATE_PRIVATE_THREADS_PERMISSION_FLAG USE_EXTERNAL_STICKERS_PERMISSION_FLAG SEND_MESSAGES_IN_THREADS_PERMISSION_FLAG USE_EMBEDDED_ACTIVITIES_PERMISSION_FLAG MODERATE_MEMBERS_PERMISSION_FLAG VIEW_CREATOR_MONETIZATION_ANALYTICS_PERMISSION_FLAG USE_SOUNDBOARD_PERMISSION_FLAG CREATE_GUILD_EXPRESSIONS_PERMISSION_FLAG CREATE_EVENTS_PERMISSION_FLAG USE_EXTERNAL_SOUNDS_PERMISSION_FLAG SEND_VOICE_MESSAGES_PERMISSION_FLAG SET_VOICE_CHANNEL_STATUS_PERMISSION_FLAG SEND_POLLS_PERMISSION_FLAG USE_EXTERNAL_APPS_PERMISSION_FLAG PIN_MESSAGES_PERMISSION_FLAG BYPASS_SLOWMODE_PERMISSION_FLAG ALL_TEXT_PERMISSION_FLAGS = VIEW_CHANNEL_PERMISSION_FLAG | SEND_MESSAGES_PERMISSION_FLAG | SEND_TTS_MESSAGES_PERMISSION_FLAG | MANAGE_MESSAGES_PERMISSION_FLAG | EMBED_LINKS_PERMISSION_FLAG | ATTACH_FILES_PERMISSION_FLAG | READ_MESSAGE_HISTORY_PERMISSION_FLAG | MENTION_EVERYONE_PERMISSION_FLAG | SEND_VOICE_MESSAGES_PERMISSION_FLAG | SEND_POLLS_PERMISSION_FLAG | USE_EXTERNAL_APPS_PERMISSION_FLAG | PIN_MESSAGES_PERMISSION_FLAG | BYPASS_SLOWMODE_PERMISSION_FLAG ALL_THREAD_PERMISSION_FLAGS = MANAGE_THREADS_PERMISSION_FLAG | CREATE_PUBLIC_THREADS_PERMISSION_FLAG | CREATE_PRIVATE_THREADS_PERMISSION_FLAG | SEND_MESSAGES_IN_THREADS_PERMISSION_FLAG ALL_VOICE_PERMISSION_FLAGS = VIEW_CHANNEL_PERMISSION_FLAG | CONNECT_PERMISSION_FLAG | SPEAK_PERMISSION_FLAG | STREAM_PERMISSION_FLAG | MUTE_MEMBERS_PERMISSION_FLAG | DEAFEN_MEMBERS_PERMISSION_FLAG | MOVE_MEMBERS_PERMISSION_FLAG | USE_VAD_PERMISSION_FLAG | PRIORITY_SPEAKER_PERMISSION_FLAG | USE_SOUNDBOARD_PERMISSION_FLAG | USE_EXTERNAL_SOUNDS_PERMISSION_FLAG | REQUEST_TO_SPEAK_PERMISSION_FLAG | USE_EMBEDDED_ACTIVITIES_PERMISSION_FLAG | SET_VOICE_CHANNEL_STATUS_PERMISSION_FLAG | CREATE_GUILD_EXPRESSIONS_PERMISSION_FLAG | CREATE_EVENTS_PERMISSION_FLAG | MANAGE_EVENTS_PERMISSION_FLAG ALL_CHANNEL_PERMISSION_FLAGS = ALL_TEXT_PERMISSION_FLAGS | ALL_THREAD_PERMISSION_FLAGS | ALL_VOICE_PERMISSION_FLAGS | CREATE_INSTANT_INVITE_PERMISSION_FLAG | MANAGE_CHANNELS_PERMISSION_FLAG | ADD_REACTIONS_PERMISSION_FLAG | USE_EXTERNAL_EMOJIS_PERMISSION_FLAG | USE_APPLICATION_COMMANDS_PERMISSION_FLAG | USE_EXTERNAL_STICKERS_PERMISSION_FLAG ALL_PERMISSION_FLAGS = ALL_CHANNEL_PERMISSION_FLAGS | KICK_MEMBERS_PERMISSION_FLAG | BAN_MEMBERS_PERMISSION_FLAG | MANAGE_GUILD_PERMISSION_FLAG | ADMINISTRATOR_PERMISSION_FLAG | MANAGE_WEBHOOKS_PERMISSION_FLAG | MANAGE_GUILD_EXPRESSIONS_PERMISSION_FLAG | VIEW_CREATOR_MONETIZATION_ANALYTICS_PERMISSION_FLAG | VIEW_GUILD_INSIGHTS_PERMISSION_FLAG | VIEW_AUDIT_LOG_PERMISSION_FLAG | MANAGE_ROLES_PERMISSION_FLAG | CHANGE_NICKNAME_PERMISSION_FLAG | MANAGE_NICKNAMES_PERMISSION_FLAG | MODERATE_MEMBERS_PERMISSION_FLAG )
type Poll ¶ added in v1.2.3
type Poll struct {
Expiry *time.Time `json:"expiry,omitempty"`
Results *PoolResult `json:"results,omitempty"`
Question PollMedia `json:"question"`
Answers []PollAnswer `json:"answers,omitzero"`
Duration uint16 `json:"duration,omitzero"` // Number of hours the poll should be open for, up to 32 days (defaults to 24)
Multiselect bool `json:"allow_multiselect"`
LayoutType PoolLayoutType `json:"layout_type"`
}
https://docs.discord.com/developers/resources/poll#poll-object
type PollAnswer ¶ added in v1.2.3
type PollAnswer struct {
PollMedia PollMedia `json:"poll_media"`
AnswerID uint32 `json:"answer_id,omitzero"`
}
https://docs.discord.com/developers/resources/poll#poll-answer-object
type PollMedia ¶ added in v1.2.3
https://docs.discord.com/developers/resources/poll#poll-media-object
type PoolAnswerCounts ¶ added in v1.2.3
type PoolAnswerCounts struct {
ID uint32 `json:"id"` // The answer_id
Count uint32 `json:"count"`
MeVoted bool `json:"me_voted"`
}
https://docs.discord.com/developers/resources/poll#poll-results-object
type PoolLayoutType ¶ added in v1.2.3
type PoolLayoutType uint8
https://docs.discord.com/developers/resources/poll#layout-type
const (
DEFAULT_POOL_LAYOUT_TYPE PoolLayoutType = iota + 1
)
type PoolResult ¶ added in v1.2.3
type PoolResult struct {
AnswerCounts []PoolAnswerCounts `json:"answer_counts"`
Finalized bool `json:"is_finalized"`
}
https://docs.discord.com/developers/resources/poll#poll-results-object
type PremiumTier ¶ added in v1.3.5
type PremiumTier uint8
https://docs.discord.com/developers/resources/guild#guild-object-premium-tier
const ( NONE_PREMIUM_TIER PremiumTier = iota BOOST_1_PREMIUM_TIER BOOST_2_PREMIUM_TIER BOOST_3_PREMIUM_TIER )
type RadioGroupComponent ¶ added in v1.6.0
type RadioGroupComponent struct {
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id,omitempty"`
Value *string `json:"value,omitempty"` // The value of the selected option, or null if no option is selected. Populated on modal submission.
Options []RadioGroupOption `json:"options,omitzero"` // List of options to show; min 2, max 10
ID uint32 `json:"id,omitzero"` // Optional identifier for component
Type ComponentType `json:"type"` // Always = RADIO_GROUP_COMPONENT_TYPE (21)
Required bool `json:"required"` // Whether a selection is required to submit the modal (defaults to true)
}
A RadioGroupComponent allows selecting exactly one option from a defined list of choices.
They can only be used inside [LabelComponent]s within modals.
https://docs.discord.com/developers/components/reference#radio-group
type RadioGroupOption ¶ added in v1.6.0
type RadioGroupOption struct {
Value string `json:"value"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
Default bool `json:"default,omitzero"` // Whether to render this option as selected by default.
}
https://docs.discord.com/developers/components/reference#radio-group-option-structure
type RateLimiter ¶ added in v1.9.0
type RateLimiter struct {
// contains filtered or unexported fields
}
func NewRateLimiter ¶ added in v1.9.0
func NewRateLimiter(opt RateLimiterOptions) *RateLimiter
type RateLimiterOptions ¶ added in v1.9.0
type Reaction ¶
type Reaction struct {
BurstColors []string `json:"burst_colors"` // HEX colors used for super reaction
Emoji Emoji `json:"emoji"`
CountDetails ReactionCountDetails `json:"count_details"`
Count uint32 `json:"count"`
Me bool `json:"me"`
MeBurst bool `json:"me_burst"`
}
https://docs.discord.com/developers/resources/message#reaction-object-reaction-structure
type ReactionCountDetails ¶ added in v1.2.3
type ReadyEventData ¶ added in v1.4.0
type ReadyEventData struct {
SessionID string `json:"session_id"`
ResumeGatewayURL string `json:"resume_gateway_url"`
Guilds []UnavailableGuild `json:"guilds"`
User User `json:"user"`
Version uint8 `json:"v"` // Version of Discord API version
}
https://docs.discord.com/developers/events/gateway-events#ready
type Response ¶ added in v1.4.0
type Response struct {
Data any `json:"data,omitempty"`
Files []File `json:"-"`
Type ResponseType `json:"type"`
}
Unified response type for all interaction replies. Data field holds one of three response data types (message/modal/auto-complete). We're using "any" type because those types are not compatible with each other and will never be used at the same time.
type ResponseAutoComplete ¶
type ResponseAutoComplete struct {
Data *ResponseAutoCompleteData `json:"data,omitempty"`
Type ResponseType `json:"type"`
}
type ResponseAutoCompleteData ¶
type ResponseAutoCompleteData struct {
Choices []CommandOptionChoice `json:"choices,omitzero"` // The autocomplete choices to show, up to 25 in total.
}
type ResponseMessage ¶
type ResponseMessage struct {
Data *ResponseMessageData `json:"data,omitempty"`
Type ResponseType `json:"type"`
}
type ResponseMessageData ¶
type ResponseMessageData struct {
AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` // Data pertaining to the message's allowed mentions.
Poll *Poll `json:"poll,omitempty"` // An optional poll to include in the message.
Content string `json:"content,omitempty"` // The message content.
Embeds []Embed `json:"embeds,omitzero"` // Up to 10 rich content embeds to include.
Components []MessageComponent `json:"components,omitzero"` // Any components to send alongside the message.
Attachments []Attachment `json:"attachments,omitzero"` // Any attachments to send alongside the message.
Flags MessageFlags `json:"flags,omitzero"` // A bitfield containing message flags. Note that only [SUPPRESS_EMBEDS_MESSAGE_FLAG], [EPHEMERAL_MESSAGE_FLAG], [IS_COMPONENTS_V2_MESSAGE_FLAG], [IS_VOICE_MESSAGE_MESSAGE_FLAG] and [SUPPRESS_NOTIFICATIONS_MESSAGE_FLAG] can be set.
TTS bool `json:"tts,omitzero"` // Whether the message is a TTS message.
}
ResponseMessageData represents the data sent for message responses.
type ResponseModal ¶
type ResponseModal struct {
Data *ResponseModalData `json:"data,omitempty"`
Type ResponseType `json:"type"`
}
type ResponseModalData ¶
type ResponseModalData struct {
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id"`
Title string `json:"title"` // The title of the modal. Must be under 45 characters.
Components []ModalComponent `json:"components,omitzero"` // 1-5 components that will make up the modal's body. Will be returned populated with user-filled data.
}
ResponseModalData represents the data sent for modal responses.
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 and modal submit interactions. UPDATE_MESSAGE_RESPONSE_TYPE // Only valid for component-based and modal submit 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 Rest ¶ added in v1.2.3
type Rest struct {
// Timeout is intentionally left unset; Rest methods apply MaxWaitTime
// through the request context so retries share one deadline.
HTTPClient http.Client
// contains filtered or unexported fields
}
func NewRest ¶ added in v1.2.3
func NewRest(opt RestOptions) *Rest
func (*Rest) BufferJSON ¶ added in v1.10.3
func (rest *Rest) BufferJSON(jsonPayload any) (io.ReadSeeker, error)
Prepares new json buffered request payload that can be used by DirectRequest() method. Please use regular Request() or RequestWithFiles() if you're not sure what you're doing.
func (*Rest) DirectRequest ¶ added in v1.10.3
func (*Rest) DirectRequestContext ¶ added in v1.11.0
func (*Rest) RequestBytes ¶ added in v1.11.0
Runs a request and returns the raw response bytes.
func (*Rest) RequestBytesContext ¶ added in v1.11.0
func (*Rest) RequestContext ¶ added in v1.11.0
func (rest *Rest) RequestContext(ctx context.Context, method, route string, jsonPayload any, into any) error
Executes a request while honoring ctx for limiter waits, retries and dial/TLS cancellation.
func (*Rest) RequestWithFiles ¶ added in v1.2.3
type RestOptions ¶ added in v1.7.0
type RestOptions struct {
// Context is the lifecycle context used by context-free Rest methods
// (Request, DirectRequest, RequestWithFiles). Gateway clients replace it
// with the context passed to ShardManager.Start. HTTP clients should set
// this to their server/application context so shutdown also stops
// post-response REST work. If nil, a background fallback is used.
Context context.Context
TraceLogger *log.Logger
Token string
RateLimiterOptions RateLimiterOptions
MaxWaitTime time.Duration // Max duration for one logical request, including retries. By default: 10 seconds.
RetryThreshold uint32 // Max number of concurrent retries allowed before failing all ongoing requests (emergency breaks). By default: 60.
MaxRetries uint8 // By default: 3
Trace bool
}
type ResumeEvent ¶ added in v1.4.0
type ResumeEvent struct {
Data ResumeEventData `json:"d"`
Opcode Opcode `json:"op"`
}
https://docs.discord.com/developers/events/gateway-events#resume
type ResumeEventData ¶ added in v1.4.0
type ResumeEventData struct {
Token string `json:"token"`
SessionID string `json:"session_id"`
Sequence uint32 `json:"seq"` // Last sequence number received
}
https://docs.discord.com/developers/events/gateway-events#resume-resume-structure
type Role ¶
type Role struct {
Colors RoleColors `json:"colors"`
Tags *RoleTag `json:"tags,omitempty"`
Name string `json:"name"`
IconHash string `json:"icon,omitempty"`
UnicodeEmoji string `json:"unicode_emoji,omitempty"`
ID Snowflake `json:"id"`
PermissionFlags PermissionFlags `json:"permissions,string"`
Flags RoleFlags `json:"flags"`
Hoist bool `json:"hoist"`
Position uint8 `json:"position"`
Managed bool `json:"managed"`
Mentionable bool `json:"mentionable"`
}
https://docs.discord.com/developers/topics/permissions#role-object
type RoleColors ¶ added in v1.10.0
type RoleColors struct {
SecondaryColor *uint32 `json:"secondary_color,omitempty"`
TertiaryColor *uint32 `json:"tertiary_color,omitempty"`
PrimaryColor uint32 `json:"primary_color"`
}
https://docs.discord.com/developers/topics/permissions#role-object-role-colors-object
type RoleFlags ¶ added in v1.11.0
type RoleFlags = BitSet
https://docs.discord.com/developers/topics/permissions#role-object-role-flags
const (
IN_PROMPT_ROLE_FLAG RoleFlags = 1 << 0
)
type RoleTag ¶
type RoleTag struct {
BotID Snowflake `json:"bot_id,omitzero"`
IntegrationID Snowflake `json:"integration_id,omitzero"` // The id of the integration this role belongs to.
SubscriptionListingID Snowflake `json:"subscription_listing_id,omitzero"` // The id of this role's subscription sku and listing.
PremiumSubscriber bool `json:"premium_subscriber"` // Whether this is the guild's Booster role.
AvailableForPurchase bool `json:"available_for_purchase"`
GuildConnections bool `json:"guild_connections"` // Whether this role is a guild's linked role.
}
https://docs.discord.com/developers/topics/permissions#role-object-role-tags-structure
type SectionComponent ¶ added in v1.3.0
type SectionComponent struct {
Accessory AccessoryComponent `json:"accessory,omitzero"` // A component contextually associated to the section's content.
Components []TextDisplayComponent `json:"components,omitzero"` // 1-3 text display components representing the section's text content.
ID uint32 `json:"id,omitzero"`
Type ComponentType `json:"type"` // Always = SECTION_COMPONENT_TYPE (9)
}
A SectionComponent associates text content with a given AccessoryComponent.
They can only be used inside messages.
https://docs.discord.com/developers/components/reference#section-section-structure
func (*SectionComponent) UnmarshalJSON ¶ added in v1.3.0
func (c *SectionComponent) UnmarshalJSON(data []byte) error
type SelectComponent ¶ added in v1.3.0
type SelectComponent struct {
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id,omitempty"`
Placeholder string `json:"placeholder,omitempty"` // Placeholder text if nothing is selected, max: 150 characters.
ChannelTypes []ChannelType `json:"channel_types,omitzero"` // List of channel types to include in the channel select component; should be omitted for all other select types.
DefaultValues []DefaultValueOption `json:"default_values,omitzero"` // List of default values for auto-populated select menu components; must have between MinValues and MaxValues entries.
Values []Snowflake `json:"values,omitzero"`
ID uint32 `json:"id,omitzero"`
MinValues uint8 `json:"min_values,omitzero"` // The minimum number of items that must be chosen; defaults to 1 and must be between 0 and 25.
MaxValues uint8 `json:"max_values,omitzero"` // The maximum number of items that can be chosen; defaults to 1 and must be between 0 and 25.
Type ComponentType `json:"type"` // Either USER_SELECT_COMPONENT_TYPE, ROLE_SELECT_COMPONENT_TYPE, MENTIONABLE_SELECT_COMPONENT_TYPE or CHANNEL_SELECT_COMPONENT_TYPE
Required bool `json:"required,omitzero"` // Whether a selection is required to submit the modal (defaults to true).
Disabled bool `json:"disabled,omitzero"` // Whether the select menu is disabled inside a message; default false. Will result in an error if used inside a modal!
}
A SelectComponent displays a drop-down menu for a user to select either Users, Roles, Mentionables or Channels. It encapsulates the User Select, Role Select, Mentionable Select and Channel Select components from Discord.
They are available in both messages and modals, but must be placed inside an ActionRowComponent or LabelComponent respectively.
type SelectMenuOption ¶
type SelectMenuOption struct {
Emoji *Emoji `json:"emoji,omitempty"` // It may only contain id, name, and animated from regular Emoji struct.
Label string `json:"label"` // Text label that appears on the option label, max 80 characters.
Value string `json:"value"` // Value to return back to app once clicked, max 100 characters.
Description string `json:"description,omitempty"` // An additional description of the option, max 100 characters.
Default bool `json:"default,omitzero"` // Whether to render this option as selected by default.
}
A SelectMenuOption represents a single option within a StringSelectComponent.
https://docs.discord.com/developers/components/reference#string-select-select-option-structure
type SeparatorComponent ¶ added in v1.3.0
type SeparatorComponent struct {
ID uint32 `json:"id,omitzero"`
Type ComponentType `json:"type"` // Always = SEPARATOR_COMPONENT_TYPE (14)
Divider bool `json:"divider,omitzero"` // Whether a visual divider should be displayed in the component (defaults to true).
Spacing uint8 `json:"spacing,omitzero"` // Size of separator padding—1 for small padding, 2 for large padding (defaults to 1).
}
https://docs.discord.com/developers/components/reference#separator-separator-structure
type SessionStartLimit ¶ added in v1.4.0
type SessionStartLimit struct {
ResetAfter uint32 `json:"reset_after"`
Total uint16 `json:"total"` // max 1000
Remaining uint16 `json:"remaining"` // max 1000
MaxConcurrency uint16 `json:"max_concurrency"` // Number of identify requests allowed per 5 seconds.
}
https://docs.discord.com/developers/events/gateway#session-start-limit-object
type Shard ¶ added in v1.4.0
type Shard struct {
ID uint16
// contains filtered or unexported fields
}
Shard represents a single connection to the Discord Gateway. It handles the full lifecycle of the connection, including identifying, heartbeating, and resuming. It is designed to be managed by a Manager.
func NewShard ¶ added in v1.4.0
func NewShard( id uint16, totalShards uint16, token string, intents uint32, zstdCompression bool, traceLogger *log.Logger, eventHandler func(shardID uint16, packet EventPacket), ) *Shard
Creates a new Shard instance - shard by default will handle own session lifecycle (identify, heartbeat, session resume).
All packets shard receives that are not related to connection lifecycle will be pushed to eventHandler function.
Set zstdCompression to true to enable zstd-stream transport compression.
Warning: Shards are intended to be used via Manager. If you don't know what you're doing - use manager instead.
func (*Shard) Start ¶ added in v1.4.0
Establishes a connection to the Discord Gateway and starts handling events. This is a blocking call that will manage the connection until the context is canceled.
func (*Shard) Status ¶ added in v1.4.0
func (s *Shard) Status() ShardState
func (*Shard) UpdatePresence ¶ added in v1.10.3
func (s *Shard) UpdatePresence(payload *UpdatePresenceEvent) error
type ShardManager ¶ added in v1.4.0
type ShardManager struct {
// contains filtered or unexported fields
}
ShardManager is responsible for orchestrating multiple Shard connections to the Discord Gateway. It handles everything that is required for Bot to start receiving packets with event data.
func NewShardManager ¶ added in v1.4.0
func NewShardManager(token string, trace bool, zstdCompression bool, eventHandler func(shardID uint16, packet EventPacket), logger *log.Logger) *ShardManager
Creates a new gateway connection manager. Set trace to true to enable detailed logging for the manager & all shards under its control. If tracing is enabled and logger is provided, it'll be used for all internal messages. If none is provided, the default Stdout logger will be used instead.
Set zstdCompression to true to enable zstd-stream transport compression.
func (*ShardManager) AllShardDetails ¶ added in v1.4.4
func (m *ShardManager) AllShardDetails() ([]ShardState, []time.Duration)
Returns shard status and ping value (calculated based on shard heartbeat) for each started shard.
func (*ShardManager) Broadcast ¶ added in v1.4.0
func (m *ShardManager) Broadcast(jsonStruct any)
Sends a payload to all online shards. This is useful for actions that affect the bot's global state, such as presence updates.
func (*ShardManager) Send ¶ added in v1.4.0
func (m *ShardManager) Send(shardID uint16, jsonStruct any)
func (*ShardManager) ShardDetails ¶ added in v1.4.4
func (m *ShardManager) ShardDetails(shardID uint16) (ShardState, time.Duration, error)
Returns shard status and ping value (calculated based on shard heartbeat).
func (*ShardManager) Start ¶ added in v1.4.0
func (m *ShardManager) Start(ctx context.Context, intents uint32, forcedShardCount uint16, launchedCallbackFn func()) error
Connects the manager to Discord. It fetches the gateway configuration, creates the necessary shards, and starts them in parallel. This is a blocking call that waits for all shards to complete their lifecycle.
Canceling ctx stops the startup process and gracefully closes every active shard. Returns nil after a context-triggered shutdown. Callers do not need a separate stop method; the context owns the connection lifecycle just like it does for an http.Server.
Note: Normally Manager will ask Discord API for recommended number of shards and use that. You can manually change that by setting forcedShardCount param to value larger than 0. There's also an option to provide a callback invoked after all shards have been launched.
func (*ShardManager) Status ¶ added in v1.4.0
func (m *ShardManager) Status() map[uint16]ShardState
func (*ShardManager) UpdateStatus ¶ added in v1.4.0
func (m *ShardManager) UpdateStatus(statusGeneratorFn func(shardID uint16) *UpdatePresenceEvent)
Allows to update status (presence) of the bot. Have generator function return nil to skip updating status for a specific shard.
type ShardState ¶ added in v1.4.0
type ShardState uint8
const ( // Represents any state that cannot be considered ready // (offline, dead, zombie connection, just disconnected, etc.). OFFLINE_SHARD_STATE ShardState = iota CONNECTING_SHARD_STATE // State where Shard's socket is connected but still in process of identifying or resuming session. AUTHENTICATING_SHARD_STATE ONLINE_SHARD_STATE )
func (ShardState) String ¶ added in v1.4.0
func (s ShardState) String() string
type SharedMap ¶ added in v1.2.3
type SharedMap[K comparable, V any] struct { // contains filtered or unexported fields }
Map but wrapped with mutex so it's safe to use between goroutines. It also supports few extra, helper methods that are new to std Map.
func NewSharedMap ¶ added in v1.2.3
func NewSharedMap[K comparable, V any]() *SharedMap[K, V]
func (*SharedMap[K, V]) Entries ¶ added in v1.7.0
Returns an iterator over the map's key-value pairs. Map contents stays locked for the entire duration of the iteration.
Warning! Do not perform any heavy computation or blocking operations (like I/O) inside the loop, as it will block all other map operations (including Writes) for the entire duration of the loop.
func (*SharedMap[K, V]) FilterKeys ¶ added in v1.3.2
Same as FilterMap but returns slice of keys that pass the provided test function.
func (*SharedMap[K, V]) FilterMap ¶ added in v1.3.2
Creates a copy of a given shared map, filtered down to just the elements from the given array that pass the test implemented by the provided function.
func (*SharedMap[K, V]) FilterValues ¶ added in v1.3.2
Same as FilterMap but returns slice of values that pass the provided test function.
func (*SharedMap[K, V]) Keys ¶ added in v1.7.0
Returns an iterator over the map's keys. Map contents stays locked for the entire duration of the iteration.
Warning! Do not perform any heavy computation or blocking operations (like I/O) inside the loop, as it will block all other map operations (including Writes) for the entire duration of the loop.
func (*SharedMap[K, V]) Sweep ¶ added in v1.2.3
Deletes items that satisfy the provided filter function within 1 mutex lock.
func (*SharedMap[K, V]) Values ¶ added in v1.7.0
Returns an iterator over the map's values. Map contents stays locked for the entire duration of the iteration.
Warning! Do not perform any heavy computation or blocking operations (like I/O) inside the loop, as it will block all other map operations (including Writes) for the entire duration of the loop.
type Snowflake ¶
type Snowflake uint64
Represents a Discord's ID snowflake.
func EnvToSnowflake ¶
Shortcut to calling os.Getenv method and casting to Snowflake.
func StringToSnowflake ¶
func (Snowflake) AppendText ¶ added in v1.11.0
func (Snowflake) CreationTimestamp ¶
func (*Snowflake) UnmarshalJSON ¶
func (*Snowflake) UnmarshalText ¶ added in v1.11.0
type StatusType ¶ added in v1.4.0
type StatusType string
const ( ONLINE_STATUS StatusType = "online" DND_STATUS StatusType = "dnd" IDLE_STATUS StatusType = "idle" INVISIBLE_STATUS StatusType = "invisible" OFFLINE_STATUS StatusType = "offline" )
type StickerFormatType ¶
type StickerFormatType uint8
https://docs.discord.com/developers/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 {
Name string `json:"name"`
ID Snowflake `json:"id"`
FormatType StickerFormatType `json:"format_type"`
}
https://docs.discord.com/developers/resources/sticker#sticker-item-object-sticker-item-structure
type StringSelectComponent ¶ added in v1.3.0
type StringSelectComponent struct {
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Options []SelectMenuOption `json:"options,omitzero"`
Values []string `json:"values,omitzero"` // The values of the options that were selected by the user. Should not be provided during message or modal creation.
ID uint32 `json:"id,omitzero"`
Type ComponentType `json:"type"` // Always = STRING_SELECT_COMPONENT_TYPE (3). Omitted inside interaction responses from messages.
ComponentType ComponentType `json:"component_type,omitzero"` // Always = STRING_SELECT_COMPONENT_TYPE (3). Omitted in anything BUT interaction responses from messages.
MinValues uint8 `json:"min_values,omitzero"` // The minimum number of options that must be chosen; defaults to 1 and must be between 0 and 25. Can only be 0 if required is set to false.
MaxValues uint8 `json:"max_values,omitzero"` // The maximum number of options that can be chosen; defaults to 1 and must be between 1 and 25.
Disabled bool `json:"disabled,omitzero"` // Whether the select menu is disabled inside a message; default false. Will result in an error if used inside a modal!
Required bool `json:"required,omitzero"` // Whether a selection is required to submit the modal; defaults to true. Will result in an error if used inside a message!
}
A StringSelectComponent displays a dropdown menu for users to select one or more pre-defined options.
They are available in both messages and modals, but must be placed inside an ActionRowComponent or LabelComponent respectively.
https://docs.discord.com/developers/components/reference#string-select-string-select-structure
type SystemChannelFlags ¶ added in v1.3.5
type SystemChannelFlags = BitSet
https://docs.discord.com/developers/resources/guild#guild-object-system-channel-flags
type TestEntitlementPayload ¶ added in v1.3.0
type TestEntitlementPayload struct {
SkuID Snowflake `json:"sku_id"`
OwnerID Snowflake `json:"owner_id"`
OwnerType EntitlementOwnerType `json:"owner_type"`
}
https://docs.discord.com/developers/resources/entitlement#create-test-entitlement-json-params
type TextDisplayComponent ¶ added in v1.3.0
type TextDisplayComponent struct {
Content string `json:"content"` // The Markdown content to display.
ID uint32 `json:"id,omitzero"`
Type ComponentType `json:"type"` // Always = TEXT_DISPLAY_COMPONENT_TYPE (10)
}
A TextDisplayComponent displays Markdown-formatted text content within a message or modal, similar to the 'content' field of a message.
https://docs.discord.com/developers/components/reference#text-display-text-display-structure
type TextInputComponent ¶ added in v1.3.0
type TextInputComponent struct {
// A unique, developer-defined identifier for this Component; must be between 1 and 100 characters long.
//
// Will be returned verbatim inside the response payload, and be used to maintain application state or store data as needed.
CustomID string `json:"custom_id,omitempty"`
Label string `json:"label,omitempty"` // Deprecated: use `label` and `description` on a Label component instead
Value string `json:"value,omitempty"` // Pre-filled value for this component; max 4000 characters. Once the user submits the modal, this will be populated with their input.
Placeholder string `json:"placeholder,omitempty"` // Placeholder text to display when no text is present. Max: 100 characters
ID uint32 `json:"id,omitzero"`
MinLength uint16 `json:"min_length,omitzero"` // min: 0, max: 4000 characters
MaxLength uint16 `json:"max_length,omitzero"` // min: 1, max: 4000 characters
Type ComponentType `json:"type"` // Always = TEXT_INPUT_COMPONENT_TYPE (4)
Style TextInputStyle `json:"style"`
Required bool `json:"required"` // Whether this component is required to be filled, defaults to true
}
A TextInputComponent displays a field for the user to input free-form text.
They can only be used inside [LabelComponent]s within modals.
https://docs.discord.com/developers/components/reference#text-input-text-input-structure
type TextInputStyle ¶
type TextInputStyle uint8
https://docs.discord.com/developers/components/reference#text-input-text-input-styles
const ( SHORT_TEXT_INPUT_STYLE TextInputStyle = iota + 1 // A single-line input. PARAGRAPH_TEXT_INPUT_STYLE // A multi-line input. )
type ThumbnailComponent ¶ added in v1.3.0
type ThumbnailComponent struct {
Description string `json:"description,omitzero"` // Alt text for the media, max 1024 characters
Media UnfurledMediaItem `json:"media"`
ID uint32 `json:"id,omitzero"`
Type ComponentType `json:"type"` // Always = THUMBNAIL_COMPONENT_TYPE (11)
Spoiler bool `json:"spoiler,omitzero"`
}
A ThumbnailComponent displays visual media as a small thumbnail within a message.
They are only available as accessories inside [SectionComponent]s.
https://docs.discord.com/developers/components/reference#thumbnail-thumbnail-structure
type UnavailableGuild ¶ added in v1.3.4
type UnavailableGuild struct {
}
https://docs.discord.com/developers/resources/guild#unavailable-guild-object
type UnfurledMediaItem ¶ added in v1.3.0
type UnfurledMediaItem struct {
URL string `json:"url"` // Supports arbitrary urls and attachment://<filename> references
ProxyURL string `json:"proxy_url,omitempty"`
ContentType string `json:"content_type,omitempty"` // This field is ignored and provided by the API as part of the response
Placeholder string `json:"placeholder,omitempty"`
AttachmentID Snowflake `json:"attachment_id,omitzero"` // This field is ignored and provided by the API as part of the response
Width uint32 `json:"width,omitzero"`
Height uint32 `json:"height,omitzero"`
PlaceholderVersion uint32 `json:"placeholder_version,omitzero"`
Flags UnfurledMediaItemFlags `json:"flags,omitzero"`
}
type UnfurledMediaItemFlags ¶ added in v1.11.0
type UnfurledMediaItemFlags = BitSet
const (
IS_ANIMATED_UNFURLED_MEDIA_ITEM_FLAG UnfurledMediaItemFlags = 1 << 0
)
type UpdatePresenceEvent ¶ added in v1.4.0
type UpdatePresenceEvent struct {
Data UpdatePresenceEventData `json:"d"`
Opcode Opcode `json:"op"`
}
https://docs.discord.com/developers/events/gateway-events#update-presence
type UpdatePresenceEventData ¶ added in v1.4.0
type UpdatePresenceEventData struct {
Since *int64 `json:"since"` // Unix time (in milliseconds) of when the client went idle, or null if the client is not idle
Status StatusType `json:"status"`
Activities []Activity `json:"activities"`
Emoji Emoji `json:"emoji"`
AFK bool `json:"afk"`
}
type User ¶
type User struct {
AvatarDecorationData *AvatarDecoration `json:"avatar_decoration_data,omitempty"`
Username string `json:"username"`
GlobalName string `json:"global_name,omitempty"` // User's display name. Tempest lib will make it equal to user.Username if it was empty.
AvatarHash string `json:"avatar,omitempty"` // Hash code used to access user's profile. Call User.AvatarURL to get direct url.
BannerHash string `json:"banner,omitempty"` // Hash code used to access user's baner. Call User.BannerURL to get direct url.
Locale string `json:"locale,omitempty"`
ID Snowflake `json:"id"`
PublicFlags UserFlags `json:"public_flags,omitzero"` // Public flags on user's account.
AccentColor uint32 `json:"accent_color,omitzero"` // User's banner color, encoded as an integer representation of hexadecimal color code.
Bot bool `json:"bot"` // Whether it's bot/app account.
System bool `json:"system"` // Whether user is Discord System Message account.
PremiumType NitroType `json:"premium_type,omitzero"`
}
https://docs.discord.com/developers/resources/user#user-object
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.
func (*User) BannerURL ¶
Returns a direct url to user's banner. It'll return empty string if targeted user don't use avatar.
func (User) DisplayName ¶ added in v1.11.0
type UserFlags ¶ added in v1.2.3
type UserFlags = BitSet
https://docs.discord.com/developers/resources/user#user-object-user-flags
const ( DISCORD_EMPLOYEE_USER_FLAG UserFlags = 1 << iota // Discord Employee, Staff PARTNERED_SERVER_OWNER_USER_FLAG // Partner HYPESQUAD_USER_FLAG BUG_HUNTER_LEVEL_1_USER_FLAG HYPESQUAD_ONLINE_HOUSE_1_USER_FLAG HYPESQUAD_ONLINE_HOUSE_2_USER_FLAG HYPESQUAD_ONLINE_HOUSE_3_USER_FLAG PREMIUM_EARLY_SUPPORTER_USER_FLAG TEAM_USER_USER_FLAG // Discord docs mentions "pseudo user" and that user is a team... BUG_HUNTER_LEVEL_2_USER_FLAG VERIFIED_BOT_USER_FLAG VERIFIED_DEVELOPER_USER_FLAG // Early Verified Bot Developer CERTIFIED_MODERATOR_USER_FLAG // Moderator Programs Alumni BOT_HTTP_INTERACTIONS_USER_FLAG // Bot/App uses only HTTP interactions and is shown in the online member list. ACTIVE_DEVELOPER_USER_FLAG // User has regular discord developer badge )
type VerificationLevel ¶ added in v1.11.0
type VerificationLevel uint8
https://docs.discord.com/developers/resources/guild#guild-object-verification-level
const ( NONE_VERIFICATION_LEVEL VerificationLevel = iota LOW_VERIFICATION_LEVEL MEDIUM_VERIFICATION_LEVEL HIGH_VERIFICATION_LEVEL VERY_HIGH_VERIFICATION_LEVEL )
Source Files
¶
- bit-set.go
- client-itx-sweeper.go
- client-registry.go
- client.go
- command.go
- component-helper.go
- component-json.go
- component-union.go
- component.go
- constant.go
- entitlement.go
- event.go
- gateway-client.go
- gateway-url.go
- guild.go
- http-client.go
- interaction-helper.go
- interaction-json.go
- interaction.go
- json_util.go
- mentionable.go
- message-json.go
- message.go
- nonce.go
- opcode.go
- permission.go
- rate-limit.go
- response.go
- rest.go
- shard-manager.go
- shard.go
- shared-map.go
- snowflake.go
- socket.go