Documentation
¶
Index ¶
- Constants
- Variables
- func MaxConcurrencyKey(shardID int, maxConcurrency int) int
- type ActivityOpt
- type AddedThreadMember
- type CloseEventCode
- type CloseHandlerFunc
- type CompressionType
- type ConfigOpt
- func WithAutoReconnect(autoReconnect bool) ConfigOpt
- func WithBrowser(browser string) ConfigOpt
- func WithCloseHandler(closeHandler CloseHandlerFunc) ConfigOpt
- func WithCompression(compression CompressionType) ConfigOpt
- func WithDefault() ConfigOpt
- func WithDefaultRateLimiterConfigOpts(opts ...RateLimiterConfigOpt) ConfigOpt
- func WithDevice(device string) ConfigOpt
- func WithDialer(dialer *websocket.Dialer) ConfigOpt
- func WithEnableRawEvents(enableRawEventEvents bool) ConfigOpt
- func WithEnableResumeURL(enableResumeURL bool) ConfigOpt
- func WithIdentifyRateLimiter(identifyRateLimiter IdentifyRateLimiter) ConfigOpt
- func WithIntents(intents ...Intents) ConfigOpt
- func WithLargeThreshold(largeThreshold int) ConfigOpt
- func WithLogger(logger *slog.Logger) ConfigOpt
- func WithOS(os string) ConfigOpt
- func WithPresenceOpts(opts ...PresenceOpt) ConfigOpt
- func WithRateLimiter(rateLimiter RateLimiter) ConfigOpt
- func WithRateLimiterConfigOpts(opts ...RateLimiterConfigOpt) ConfigOpt
- func WithResumeURL(url string) ConfigOpt
- func WithSequence(sequence int) ConfigOpt
- func WithSessionID(sessionID string) ConfigOpt
- func WithShardCount(shardCount int) ConfigOpt
- func WithShardID(shardID int) ConfigOpt
- func WithURL(url string) ConfigOpt
- type CreateFunc
- type EventApplicationCommandPermissionsUpdate
- type EventAutoModerationActionExecution
- type EventAutoModerationRuleCreate
- type EventAutoModerationRuleDelete
- type EventAutoModerationRuleUpdate
- type EventChannelCreate
- type EventChannelDelete
- type EventChannelPinsUpdate
- type EventChannelUpdate
- type EventData
- type EventEntitlementCreate
- type EventEntitlementDelete
- type EventEntitlementUpdate
- type EventGuildAuditLogEntryCreate
- type EventGuildBanAdd
- type EventGuildBanRemove
- type EventGuildCreate
- type EventGuildDelete
- type EventGuildEmojisUpdate
- type EventGuildIntegrationsUpdate
- type EventGuildMemberAdd
- type EventGuildMemberRemove
- type EventGuildMemberUpdate
- type EventGuildMembersChunk
- type EventGuildRoleCreate
- type EventGuildRoleDelete
- type EventGuildRoleUpdate
- type EventGuildScheduledEventCreate
- type EventGuildScheduledEventDelete
- type EventGuildScheduledEventUpdate
- type EventGuildScheduledEventUserAdd
- type EventGuildScheduledEventUserRemove
- type EventGuildSoundboardSoundCreate
- type EventGuildSoundboardSoundDelete
- type EventGuildSoundboardSoundUpdate
- type EventGuildSoundboardSoundsUpdate
- type EventGuildStickersUpdate
- type EventGuildUpdate
- type EventHandlerFunc
- type EventHeartbeatAck
- type EventIntegrationCreate
- type EventIntegrationDelete
- type EventIntegrationUpdate
- type EventInteractionCreate
- type EventInviteCreate
- type EventInviteDelete
- type EventMessageCreate
- type EventMessageDelete
- type EventMessageDeleteBulk
- type EventMessagePollVoteAdd
- type EventMessagePollVoteRemove
- type EventMessageReactionAdd
- type EventMessageReactionRemove
- type EventMessageReactionRemoveAll
- type EventMessageReactionRemoveEmoji
- type EventMessageUpdate
- type EventPresenceUpdate
- type EventRateLimited
- type EventRaw
- type EventReady
- type EventResumed
- type EventSoundboardSounds
- type EventStageInstanceCreate
- type EventStageInstanceDelete
- type EventStageInstanceUpdate
- type EventSubscriptionCreate
- type EventSubscriptionDelete
- type EventSubscriptionUpdate
- type EventThreadCreate
- type EventThreadDelete
- type EventThreadListSync
- type EventThreadMemberUpdate
- type EventThreadMembersUpdate
- type EventThreadUpdate
- type EventType
- type EventTypingStart
- type EventUnknown
- type EventUserUpdate
- type EventVoiceChannelEffectSend
- type EventVoiceServerUpdate
- type EventVoiceStateUpdate
- type EventWebhooksUpdate
- type Gateway
- type IdentifyCommandDataProperties
- type IdentifyRateLimiter
- type IdentifyRateLimiterConfigOpt
- type Intents
- type Message
- type MessageData
- type MessageDataHeartbeat
- type MessageDataHeartbeatACK
- type MessageDataHello
- type MessageDataIdentify
- type MessageDataInvalidSession
- type MessageDataPresenceUpdate
- type MessageDataReconnect
- type MessageDataRequestGuildMembers
- type MessageDataRequestSoundboardSounds
- type MessageDataResume
- type MessageDataUnknown
- type MessageDataVoiceStateUpdate
- type Opcode
- type PresenceOpt
- func WithAfk(afk bool) PresenceOpt
- func WithCompetingActivity(name string, opts ...ActivityOpt) PresenceOpt
- func WithCustomActivity(status string, opts ...ActivityOpt) PresenceOpt
- func WithListeningActivity(name string, opts ...ActivityOpt) PresenceOpt
- func WithOnlineStatus(status discord.OnlineStatus) PresenceOpt
- func WithPlayingActivity(name string, opts ...ActivityOpt) PresenceOpt
- func WithSince(since *int64) PresenceOpt
- func WithStreamingActivity(name string, url string, opts ...ActivityOpt) PresenceOpt
- func WithWatchingActivity(name string, opts ...ActivityOpt) PresenceOpt
- type RateLimitedMetadata
- type RateLimitedMetadataRequestGuildMembers
- type RateLimitedMetadataUnknown
- type RateLimiter
- type RateLimiterCommandType
- type RateLimiterConfigOpt
- type Status
Constants ¶
const CommandsPerMinute = 120
CommandsPerMinute is the default number of commands per minute that the Gateway will allow.
const DefaultMaxConcurrency = 1
DefaultMaxConcurrency is the default number of shards that can log in at the same time.
const ReservedCommandSlots = 3
ReservedCommandSlots is the default number of CommandsPerMinute that the library will reserve for high priority events, like heartbeats
const URL = "wss://gateway.discord.gg"
URL is the default URL used to connect to the Discord gateway.
const Version = 10
Version defines which discord API version disgo should use to connect to discord.
Variables ¶
var ( CloseEventCodeUnknownError = CloseEventCode{ Code: 4000, Description: "Unknown error", Explanation: "We're not sure what went wrong. Try reconnecting?", Reconnect: true, } CloseEventCodeUnknownOpcode = CloseEventCode{ Code: 4001, Description: "Unknown opcode", Explanation: "You sent an invalid Gateway opcode or an invalid payload for an opcode. Don't do that!", Reconnect: true, } CloseEventCodeDecodeError = CloseEventCode{ Code: 4002, Description: "Decode error", Explanation: "You sent an invalid payload to Discord. Don't do that!", Reconnect: true, } CloseEventCodeNotAuthenticated = CloseEventCode{ Code: 4003, Description: "Not authenticated", Explanation: "You sent us a payload prior to identifying.", Reconnect: true, } CloseEventCodeAuthenticationFailed = CloseEventCode{ Code: 4004, Description: "Authentication failed", Explanation: "The account token sent with your identify payload is incorrect.", Reconnect: false, } CloseEventCodeAlreadyAuthenticated = CloseEventCode{ Code: 4005, Description: "Already authenticated", Explanation: "You sent more than one identify payload. Don't do that!", Reconnect: true, } CloseEventCodeInvalidSeq = CloseEventCode{ Code: 4007, Description: "Invalid seq", Explanation: "The sequence sent when resuming the session was invalid. Reconnect and start a new session.", Reconnect: true, } CloseEventCodeRateLimited = CloseEventCode{ Code: 4008, Description: "Rate limited.", Explanation: "You're sending payloads to us too quickly. Slow it down! You will be disconnected on receiving this.", Reconnect: true, } CloseEventCodeSessionTimed = CloseEventCode{ Code: 4009, Description: "Session timed out", Explanation: "Your session timed out. Reconnect and start a new one.", Reconnect: true, } CloseEventCodeInvalidShard = CloseEventCode{ Code: 4010, Description: "Invalid shard", Explanation: "You sent us an invalid shard when identifying.", Reconnect: false, } CloseEventCodeShardingRequired = CloseEventCode{ Code: 4011, Description: "Sharding required", Explanation: "The session would have handled too many guilds - you are required to shard your connection in order to connect.", Reconnect: false, } CloseEventCodeInvalidAPIVersion = CloseEventCode{ Code: 4012, Description: "Invalid API version", Explanation: "You sent an invalid version for the gateway.", Reconnect: false, } CloseEventCodeInvalidIntent = CloseEventCode{ Code: 4013, Description: "Invalid intent(s)", Explanation: "You sent an invalid intent for a Gateway Intent. You may have incorrectly calculated the bitwise value.", Reconnect: false, } CloseEventCodeDisallowedIntent = CloseEventCode{ Code: 4014, Description: "Disallowed intent(s)", Explanation: "You sent a disallowed intent for a Gateway Intent. You may have tried to specify an intent that you have not enabled or are not approved for.", Reconnect: false, } CloseEventCodeUnknown = CloseEventCode{ Code: 0, Description: "Unknown", Explanation: "Unknown Gateway Close Event Code", Reconnect: true, } CloseEventCodes = map[int]CloseEventCode{ CloseEventCodeUnknownError.Code: CloseEventCodeUnknownError, CloseEventCodeUnknownOpcode.Code: CloseEventCodeUnknownOpcode, CloseEventCodeDecodeError.Code: CloseEventCodeDecodeError, CloseEventCodeNotAuthenticated.Code: CloseEventCodeNotAuthenticated, CloseEventCodeAuthenticationFailed.Code: CloseEventCodeAuthenticationFailed, CloseEventCodeAlreadyAuthenticated.Code: CloseEventCodeAlreadyAuthenticated, CloseEventCodeInvalidSeq.Code: CloseEventCodeInvalidSeq, CloseEventCodeRateLimited.Code: CloseEventCodeRateLimited, CloseEventCodeSessionTimed.Code: CloseEventCodeSessionTimed, CloseEventCodeInvalidShard.Code: CloseEventCodeInvalidShard, CloseEventCodeInvalidAPIVersion.Code: CloseEventCodeInvalidAPIVersion, CloseEventCodeInvalidIntent.Code: CloseEventCodeInvalidIntent, CloseEventCodeDisallowedIntent.Code: CloseEventCodeDisallowedIntent, } )
Functions ¶
func MaxConcurrencyKey ¶ added in v0.19.0
MaxConcurrencyKey returns the bucket the given shardID with maxConcurrency belongs to.
Types ¶
type ActivityOpt ¶ added in v0.16.9
ActivityOpt is a type alias for a function that sets optional data for an Activity
func WithActivityState ¶ added in v0.16.9
func WithActivityState(state string) ActivityOpt
WithActivityState sets the Activity.State
type AddedThreadMember ¶ added in v0.13.0
type CloseEventCode ¶ added in v0.13.0
func CloseEventCodeByCode ¶ added in v0.15.0
func CloseEventCodeByCode(code int) CloseEventCode
type CloseHandlerFunc ¶ added in v0.11.0
CloseHandlerFunc is a function that is called when the Gateway is closed.
type CompressionType ¶ added in v0.19.0
type CompressionType string
CompressionType defines the compression mechanism to use for a gateway connection
const ( CompressionNone CompressionType = "" CompressionZlibPayload CompressionType = "zlib-payload" CompressionZlibStream CompressionType = "zlib-stream" CompressionZstdStream CompressionType = "zstd-stream" )
func (CompressionType) IsPayloadCompression ¶ added in v0.19.0
func (t CompressionType) IsPayloadCompression() bool
IsPayloadCompression returns whether the compression affects only payloads
func (CompressionType) IsStreamCompression ¶ added in v0.19.0
func (t CompressionType) IsStreamCompression() bool
IsStreamCompression returns whether the compression affects the whole stream
func (CompressionType) String ¶ added in v0.19.0
func (t CompressionType) String() string
type ConfigOpt ¶
type ConfigOpt func(config *config)
ConfigOpt is a type alias for a function that takes a config and is used to configure your Server.
func WithAutoReconnect ¶
WithAutoReconnect sets whether the Gateway should automatically reconnect to Discord.
func WithBrowser ¶
WithBrowser sets the browser the bot is running on. See here for more information: https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
func WithCloseHandler ¶ added in v0.19.0
func WithCloseHandler(closeHandler CloseHandlerFunc) ConfigOpt
WithCloseHandler sets the CloseHandlerFunc for the Gateway. The CloseHandlerFunc is called when the Gateway connection is closed and auto-reconnect is disabled or the close code can't be handled by the Gateway itself. If you are using the sharding package you should use [sharding.WithCloseHandler] instead.
func WithCompression ¶ added in v0.19.0
func WithCompression(compression CompressionType) ConfigOpt
WithCompression sets the compression mechanism to use. See here for more information: https://discord.com/developers/docs/topics/gateway#encoding-and-compression
func WithDefault ¶ added in v0.19.0
func WithDefault() ConfigOpt
WithDefault returns a ConfigOpt that sets the default values for the Gateway.
func WithDefaultRateLimiterConfigOpts ¶ added in v0.19.0
func WithDefaultRateLimiterConfigOpts(opts ...RateLimiterConfigOpt) ConfigOpt
WithDefaultRateLimiterConfigOpts lets you configure the default RateLimiter and prepend the options to the existing ones.
func WithDevice ¶
WithDevice sets the device the bot is running on. See here for more information: https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
func WithDialer ¶ added in v0.10.0
WithDialer sets the websocket.Dialer for the Gateway.
func WithEnableRawEvents ¶ added in v0.13.0
WithEnableRawEvents enables/disables the EventTypeRaw.
func WithEnableResumeURL ¶ added in v0.13.18
WithEnableResumeURL enables/disables usage of resume URLs sent by Discord.
func WithIdentifyRateLimiter ¶ added in v0.19.0
func WithIdentifyRateLimiter(identifyRateLimiter IdentifyRateLimiter) ConfigOpt
WithIdentifyRateLimiter sets the IdentifyRateLimiter for the Gateway.
func WithIntents ¶ added in v0.13.0
WithIntents sets the Intents for the Gateway. See here for more information: https://discord.com/developers/docs/topics/gateway#gateway-intents
func WithLargeThreshold ¶
WithLargeThreshold sets the threshold for the Gateway. See here for more information: https://discord.com/developers/docs/topics/gateway#identify-identify-structure
func WithLogger ¶
WithLogger sets the Logger for the Gateway.
func WithOS ¶
WithOS sets the operating system the bot is running on. See here for more information: https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
func WithPresenceOpts ¶ added in v0.13.19
func WithPresenceOpts(opts ...PresenceOpt) ConfigOpt
WithPresenceOpts allows to pass initial presence data the bot should display.
func WithRateLimiter ¶
func WithRateLimiter(rateLimiter RateLimiter) ConfigOpt
WithRateLimiter sets the grate.RateLimiter for the Gateway.
func WithRateLimiterConfigOpts ¶
func WithRateLimiterConfigOpts(opts ...RateLimiterConfigOpt) ConfigOpt
WithRateLimiterConfigOpts lets you configure the default RateLimiter.
func WithResumeURL ¶ added in v0.19.0
WithResumeURL sets the Gateway Resume URL for the Gateway.
func WithSequence ¶
WithSequence sets the last sequence received for the Gateway. If sessionID and lastSequence is present while connecting, the Gateway will try to resume the session.
func WithSessionID ¶
WithSessionID sets the Session ID for the Gateway. If sessionID and lastSequence is present while connecting, the Gateway will try to resume the session.
func WithShardCount ¶
WithShardCount sets the shard count for the Gateway. See here for more information on sharding: https://discord.com/developers/docs/topics/gateway#sharding
func WithShardID ¶
WithShardID sets the shard ID for the Gateway. See here for more information on sharding: https://discord.com/developers/docs/topics/gateway#sharding
type CreateFunc ¶
type CreateFunc func(token string, eventHandlerFunc EventHandlerFunc, opts ...ConfigOpt) Gateway
CreateFunc is a type that is used to create a new Gateway(s).
type EventApplicationCommandPermissionsUpdate ¶ added in v0.13.0
type EventApplicationCommandPermissionsUpdate struct {
discord.ApplicationCommandPermissions
}
type EventAutoModerationActionExecution ¶ added in v0.13.0
type EventAutoModerationActionExecution struct {
GuildID snowflake.ID `json:"guild_id"`
Action discord.AutoModerationAction `json:"action"`
RuleID snowflake.ID `json:"rule_id"`
RuleTriggerType discord.AutoModerationTriggerType `json:"rule_trigger_type"`
UserID snowflake.ID `json:"user_id"`
ChannelID *snowflake.ID `json:"channel_id,omitempty"`
MessageID *snowflake.ID `json:"message_id,omitempty"`
AlertSystemMessageID snowflake.ID `json:"alert_system_message_id"`
Content string `json:"content"`
MatchedKeywords *string `json:"matched_keywords"`
MatchedContent *string `json:"matched_content"`
}
type EventAutoModerationRuleCreate ¶ added in v0.13.0
type EventAutoModerationRuleCreate struct {
discord.AutoModerationRule
}
type EventAutoModerationRuleDelete ¶ added in v0.13.0
type EventAutoModerationRuleDelete struct {
discord.AutoModerationRule
}
type EventAutoModerationRuleUpdate ¶ added in v0.13.0
type EventAutoModerationRuleUpdate struct {
discord.AutoModerationRule
}
type EventChannelCreate ¶ added in v0.13.0
type EventChannelCreate struct {
discord.GuildChannel
}
func (*EventChannelCreate) UnmarshalJSON ¶ added in v0.13.0
func (e *EventChannelCreate) UnmarshalJSON(data []byte) error
type EventChannelDelete ¶ added in v0.13.0
type EventChannelDelete struct {
discord.GuildChannel
}
func (*EventChannelDelete) UnmarshalJSON ¶ added in v0.13.0
func (e *EventChannelDelete) UnmarshalJSON(data []byte) error
type EventChannelPinsUpdate ¶ added in v0.13.0
type EventChannelUpdate ¶ added in v0.13.0
type EventChannelUpdate struct {
discord.GuildChannel
}
func (*EventChannelUpdate) UnmarshalJSON ¶ added in v0.13.0
func (e *EventChannelUpdate) UnmarshalJSON(data []byte) error
type EventData ¶ added in v0.13.0
type EventData interface {
MessageData
// contains filtered or unexported methods
}
EventData is the base interface for all data types sent by discord
type EventEntitlementCreate ¶ added in v0.16.11
type EventEntitlementCreate struct {
discord.Entitlement
}
type EventEntitlementDelete ¶ added in v0.16.11
type EventEntitlementDelete struct {
discord.Entitlement
}
type EventEntitlementUpdate ¶ added in v0.16.11
type EventEntitlementUpdate struct {
discord.Entitlement
}
type EventGuildAuditLogEntryCreate ¶ added in v0.15.0
type EventGuildAuditLogEntryCreate struct {
discord.AuditLogEntry
GuildID snowflake.ID `json:"guild_id"`
}
type EventGuildBanAdd ¶ added in v0.13.0
type EventGuildBanRemove ¶ added in v0.13.0
type EventGuildCreate ¶ added in v0.13.0
type EventGuildCreate struct {
discord.GatewayGuild
}
type EventGuildDelete ¶ added in v0.13.0
type EventGuildDelete struct {
}
type EventGuildEmojisUpdate ¶ added in v0.13.0
type EventGuildEmojisUpdate struct {
GuildID snowflake.ID `json:"guild_id"`
Emojis []discord.Emoji `json:"emojis"`
}
func (*EventGuildEmojisUpdate) UnmarshalJSON ¶ added in v0.15.0
func (e *EventGuildEmojisUpdate) UnmarshalJSON(data []byte) error
type EventGuildIntegrationsUpdate ¶ added in v0.13.0
type EventGuildMemberAdd ¶ added in v0.13.0
type EventGuildMemberRemove ¶ added in v0.13.0
type EventGuildMemberUpdate ¶ added in v0.13.0
type EventGuildMembersChunk ¶ added in v0.13.0
type EventGuildMembersChunk struct {
GuildID snowflake.ID `json:"guild_id"`
Members []discord.Member `json:"members"`
ChunkIndex int `json:"chunk_index"`
ChunkCount int `json:"chunk_count"`
NotFound []snowflake.ID `json:"not_found"`
Presences []discord.Presence `json:"presences"`
Nonce string `json:"nonce"`
}
type EventGuildRoleCreate ¶ added in v0.13.0
type EventGuildRoleCreate struct {
GuildID snowflake.ID `json:"guild_id"`
Role discord.Role `json:"role"`
}
func (*EventGuildRoleCreate) MarshalJSON ¶ added in v0.15.0
func (e *EventGuildRoleCreate) MarshalJSON() ([]byte, error)
func (*EventGuildRoleCreate) UnmarshalJSON ¶ added in v0.15.0
func (e *EventGuildRoleCreate) UnmarshalJSON(data []byte) error
type EventGuildRoleDelete ¶ added in v0.13.0
type EventGuildRoleUpdate ¶ added in v0.13.0
type EventGuildRoleUpdate struct {
GuildID snowflake.ID `json:"guild_id"`
Role discord.Role `json:"role"`
}
func (*EventGuildRoleUpdate) MarshalJSON ¶ added in v0.15.0
func (e *EventGuildRoleUpdate) MarshalJSON() ([]byte, error)
func (*EventGuildRoleUpdate) UnmarshalJSON ¶ added in v0.15.0
func (e *EventGuildRoleUpdate) UnmarshalJSON(data []byte) error
type EventGuildScheduledEventCreate ¶ added in v0.13.0
type EventGuildScheduledEventCreate struct {
discord.GuildScheduledEvent
}
type EventGuildScheduledEventDelete ¶ added in v0.13.0
type EventGuildScheduledEventDelete struct {
discord.GuildScheduledEvent
}
type EventGuildScheduledEventUpdate ¶ added in v0.13.0
type EventGuildScheduledEventUpdate struct {
discord.GuildScheduledEvent
}
type EventGuildScheduledEventUserAdd ¶ added in v0.13.0
type EventGuildScheduledEventUserRemove ¶ added in v0.13.0
type EventGuildSoundboardSoundCreate ¶ added in v0.18.13
type EventGuildSoundboardSoundCreate struct {
discord.SoundboardSound
}
type EventGuildSoundboardSoundDelete ¶ added in v0.18.13
type EventGuildSoundboardSoundUpdate ¶ added in v0.18.13
type EventGuildSoundboardSoundUpdate struct {
discord.SoundboardSound
}
type EventGuildSoundboardSoundsUpdate ¶ added in v0.18.13
type EventGuildSoundboardSoundsUpdate struct {
SoundboardSounds []discord.SoundboardSound `json:"soundboard_sounds"`
GuildID snowflake.ID `json:"guild_id"`
}
type EventGuildStickersUpdate ¶ added in v0.13.0
type EventGuildUpdate ¶ added in v0.13.0
type EventGuildUpdate struct {
discord.GatewayGuild
}
type EventHandlerFunc ¶
type EventHandlerFunc func(gateway Gateway, eventType EventType, sequenceNumber int, event EventData)
EventHandlerFunc is a function that is called when an event is received.
type EventHeartbeatAck ¶ added in v0.16.0
type EventIntegrationCreate ¶ added in v0.13.0
type EventIntegrationCreate struct {
discord.Integration
GuildID snowflake.ID `json:"guild_id"`
}
func (EventIntegrationCreate) MarshalJSON ¶ added in v0.18.14
func (e EventIntegrationCreate) MarshalJSON() ([]byte, error)
func (*EventIntegrationCreate) UnmarshalJSON ¶ added in v0.13.0
func (e *EventIntegrationCreate) UnmarshalJSON(data []byte) error
type EventIntegrationDelete ¶ added in v0.13.0
type EventIntegrationUpdate ¶ added in v0.13.0
type EventIntegrationUpdate struct {
discord.Integration
GuildID snowflake.ID `json:"guild_id"`
}
func (EventIntegrationUpdate) MarshalJSON ¶ added in v0.18.14
func (e EventIntegrationUpdate) MarshalJSON() ([]byte, error)
func (*EventIntegrationUpdate) UnmarshalJSON ¶ added in v0.13.0
func (e *EventIntegrationUpdate) UnmarshalJSON(data []byte) error
type EventInteractionCreate ¶ added in v0.13.0
type EventInteractionCreate struct {
discord.Interaction
}
func (EventInteractionCreate) MarshalJSON ¶ added in v0.15.1
func (e EventInteractionCreate) MarshalJSON() ([]byte, error)
func (*EventInteractionCreate) UnmarshalJSON ¶ added in v0.13.0
func (e *EventInteractionCreate) UnmarshalJSON(data []byte) error
type EventInviteCreate ¶ added in v0.13.0
type EventInviteCreate struct {
ChannelID snowflake.ID `json:"channel_id"`
Code string `json:"code"`
CreatedAt time.Time `json:"created_at"`
GuildID *snowflake.ID `json:"guild_id"`
Inviter *discord.User `json:"inviter"`
MaxAge int `json:"max_age"`
MaxUses int `json:"max_uses"`
TargetType discord.InviteTargetType `json:"target_type"`
TargetUser *discord.User `json:"target_user"`
TargetApplication *discord.PartialApplication `json:"target_application"`
Temporary bool `json:"temporary"`
Uses int `json:"uses"`
ExpiresAt *time.Time `json:"expires_at"`
RoleIDs *[]snowflake.ID `json:"role_ids"`
}
type EventInviteDelete ¶ added in v0.13.0
type EventMessageCreate ¶ added in v0.13.0
type EventMessageDelete ¶ added in v0.13.0
type EventMessageDeleteBulk ¶ added in v0.13.0
type EventMessagePollVoteAdd ¶ added in v0.18.3
type EventMessagePollVoteRemove ¶ added in v0.18.3
type EventMessageReactionAdd ¶ added in v0.13.0
type EventMessageReactionAdd struct {
UserID snowflake.ID `json:"user_id"`
ChannelID snowflake.ID `json:"channel_id"`
MessageID snowflake.ID `json:"message_id"`
GuildID *snowflake.ID `json:"guild_id"`
Member *discord.Member `json:"member"`
Emoji discord.PartialEmoji `json:"emoji"`
MessageAuthorID *snowflake.ID `json:"message_author_id"`
BurstColors []string `json:"burst_colors"`
Burst bool `json:"burst"`
Type discord.MessageReactionType `json:"type"`
}
func (*EventMessageReactionAdd) UnmarshalJSON ¶ added in v0.15.0
func (e *EventMessageReactionAdd) UnmarshalJSON(data []byte) error
type EventMessageReactionRemove ¶ added in v0.13.0
type EventMessageReactionRemove struct {
UserID snowflake.ID `json:"user_id"`
ChannelID snowflake.ID `json:"channel_id"`
MessageID snowflake.ID `json:"message_id"`
GuildID *snowflake.ID `json:"guild_id"`
Emoji discord.PartialEmoji `json:"emoji"`
BurstColors []string `json:"burst_colors"`
Burst bool `json:"burst"`
Type discord.MessageReactionType `json:"type"`
}
type EventMessageReactionRemoveAll ¶ added in v0.13.0
type EventMessageReactionRemoveEmoji ¶ added in v0.13.0
type EventMessageUpdate ¶ added in v0.13.0
type EventPresenceUpdate ¶ added in v0.13.0
type EventRateLimited ¶ added in v0.19.0
type EventRateLimited struct {
Opcode Opcode `json:"opcode"`
RetryAfter float64 `json:"retry_after"`
Meta RateLimitedMetadata `json:"meta"`
}
func (*EventRateLimited) UnmarshalJSON ¶ added in v0.19.0
func (e *EventRateLimited) UnmarshalJSON(data []byte) error
type EventReady ¶ added in v0.13.0
type EventReady struct {
Version int `json:"v"`
User discord.OAuth2User `json:"user"`
Guilds []discord.UnavailableGuild `json:"guilds"`
SessionID string `json:"session_id"`
ResumeGatewayURL string `json:"resume_gateway_url"`
Shard [2]int `json:"shard,omitempty"`
Application discord.PartialApplication `json:"application"`
}
EventReady is the event sent by discord when you successfully Identify
type EventResumed ¶ added in v0.19.0
type EventResumed struct{}
EventResumed is the event sent by discord when you successfully resume
type EventSoundboardSounds ¶ added in v0.18.13
type EventSoundboardSounds struct {
SoundboardSounds []discord.SoundboardSound `json:"soundboard_sounds"`
GuildID snowflake.ID `json:"guild_id"`
}
type EventStageInstanceCreate ¶ added in v0.13.0
type EventStageInstanceCreate struct {
discord.StageInstance
}
type EventStageInstanceDelete ¶ added in v0.13.0
type EventStageInstanceDelete struct {
discord.StageInstance
}
type EventStageInstanceUpdate ¶ added in v0.13.0
type EventStageInstanceUpdate struct {
discord.StageInstance
}
type EventSubscriptionCreate ¶ added in v0.18.11
type EventSubscriptionCreate struct {
discord.Subscription
}
type EventSubscriptionDelete ¶ added in v0.18.11
type EventSubscriptionDelete struct {
discord.Subscription
}
type EventSubscriptionUpdate ¶ added in v0.18.11
type EventSubscriptionUpdate struct {
discord.Subscription
}
type EventThreadCreate ¶ added in v0.13.0
type EventThreadCreate struct {
discord.GuildThread
ThreadMember discord.ThreadMember `json:"thread_member"`
NewlyCreated bool `json:"newly_created"`
}
func (EventThreadCreate) MarshalJSON ¶ added in v0.18.14
func (e EventThreadCreate) MarshalJSON() ([]byte, error)
func (*EventThreadCreate) UnmarshalJSON ¶ added in v0.18.14
func (e *EventThreadCreate) UnmarshalJSON(data []byte) error
type EventThreadDelete ¶ added in v0.13.0
type EventThreadListSync ¶ added in v0.13.0
type EventThreadListSync struct {
GuildID snowflake.ID `json:"guild_id"`
ChannelIDs []snowflake.ID `json:"channel_ids"`
Threads []discord.GuildThread `json:"threads"`
Members []discord.ThreadMember `json:"members"`
}
type EventThreadMemberUpdate ¶ added in v0.13.0
type EventThreadMemberUpdate struct {
discord.ThreadMember
}
type EventThreadMembersUpdate ¶ added in v0.13.0
type EventThreadUpdate ¶ added in v0.13.0
type EventThreadUpdate struct {
discord.GuildThread
}
type EventType ¶ added in v0.13.0
type EventType string
EventType wraps all EventType types
const ( // EventTypeRaw is not a real event type, but is used to pass raw payloads to the bot.EventManager EventTypeRaw EventType = "__RAW__" EventTypeHeartbeatAck EventType = "__HEARTBEAT_ACK__" EventTypeReady EventType = "READY" EventTypeResumed EventType = "RESUMED" EventTypeRateLimited EventType = "RATE_LIMITED" EventTypeApplicationCommandPermissionsUpdate EventType = "APPLICATION_COMMAND_PERMISSIONS_UPDATE" EventTypeAutoModerationRuleCreate EventType = "AUTO_MODERATION_RULE_CREATE" EventTypeAutoModerationRuleUpdate EventType = "AUTO_MODERATION_RULE_UPDATE" EventTypeAutoModerationRuleDelete EventType = "AUTO_MODERATION_RULE_DELETE" EventTypeAutoModerationActionExecution EventType = "AUTO_MODERATION_ACTION_EXECUTION" EventTypeChannelCreate EventType = "CHANNEL_CREATE" EventTypeChannelUpdate EventType = "CHANNEL_UPDATE" EventTypeChannelDelete EventType = "CHANNEL_DELETE" EventTypeChannelPinsUpdate EventType = "CHANNEL_PINS_UPDATE" EventTypeEntitlementCreate EventType = "ENTITLEMENT_CREATE" EventTypeEntitlementUpdate EventType = "ENTITLEMENT_UPDATE" EventTypeEntitlementDelete EventType = "ENTITLEMENT_DELETE" EventTypeThreadCreate EventType = "THREAD_CREATE" EventTypeThreadUpdate EventType = "THREAD_UPDATE" EventTypeThreadDelete EventType = "THREAD_DELETE" EventTypeThreadListSync EventType = "THREAD_LIST_SYNC" EventTypeThreadMemberUpdate EventType = "THREAD_MEMBER_UPDATE" EventTypeThreadMembersUpdate EventType = "THREAD_MEMBERS_UPDATE" EventTypeGuildCreate EventType = "GUILD_CREATE" EventTypeGuildUpdate EventType = "GUILD_UPDATE" EventTypeGuildDelete EventType = "GUILD_DELETE" EventTypeGuildAuditLogEntryCreate EventType = "GUILD_AUDIT_LOG_ENTRY_CREATE" EventTypeGuildBanAdd EventType = "GUILD_BAN_ADD" EventTypeGuildBanRemove EventType = "GUILD_BAN_REMOVE" EventTypeGuildEmojisUpdate EventType = "GUILD_EMOJIS_UPDATE" EventTypeGuildStickersUpdate EventType = "GUILD_STICKERS_UPDATE" EventTypeGuildIntegrationsUpdate EventType = "GUILD_INTEGRATIONS_UPDATE" EventTypeGuildMemberAdd EventType = "GUILD_MEMBER_ADD" EventTypeGuildMemberRemove EventType = "GUILD_MEMBER_REMOVE" EventTypeGuildMemberUpdate EventType = "GUILD_MEMBER_UPDATE" EventTypeGuildMembersChunk EventType = "GUILD_MEMBERS_CHUNK" EventTypeGuildRoleCreate EventType = "GUILD_ROLE_CREATE" EventTypeGuildRoleUpdate EventType = "GUILD_ROLE_UPDATE" EventTypeGuildRoleDelete EventType = "GUILD_ROLE_DELETE" EventTypeGuildScheduledEventCreate EventType = "GUILD_SCHEDULED_EVENT_CREATE" EventTypeGuildScheduledEventUpdate EventType = "GUILD_SCHEDULED_EVENT_UPDATE" EventTypeGuildScheduledEventDelete EventType = "GUILD_SCHEDULED_EVENT_DELETE" EventTypeGuildScheduledEventUserAdd EventType = "GUILD_SCHEDULED_EVENT_USER_ADD" EventTypeGuildScheduledEventUserRemove EventType = "GUILD_SCHEDULED_EVENT_USER_REMOVE" EventTypeGuildSoundboardSoundCreate EventType = "GUILD_SOUNDBOARD_SOUND_CREATE" EventTypeGuildSoundboardSoundUpdate EventType = "GUILD_SOUNDBOARD_SOUND_UPDATE" EventTypeGuildSoundboardSoundDelete EventType = "GUILD_SOUNDBOARD_SOUND_DELETE" EventTypeGuildSoundboardSoundsUpdate EventType = "GUILD_SOUNDBOARD_SOUNDS_UPDATE" EventTypeIntegrationCreate EventType = "INTEGRATION_CREATE" EventTypeIntegrationUpdate EventType = "INTEGRATION_UPDATE" EventTypeIntegrationDelete EventType = "INTEGRATION_DELETE" EventTypeInteractionCreate EventType = "INTERACTION_CREATE" EventTypeInviteCreate EventType = "INVITE_CREATE" EventTypeInviteDelete EventType = "INVITE_DELETE" EventTypeMessageCreate EventType = "MESSAGE_CREATE" EventTypeMessageUpdate EventType = "MESSAGE_UPDATE" EventTypeMessageDelete EventType = "MESSAGE_DELETE" EventTypeMessageDeleteBulk EventType = "MESSAGE_DELETE_BULK" EventTypeMessagePollVoteAdd EventType = "MESSAGE_POLL_VOTE_ADD" EventTypeMessagePollVoteRemove EventType = "MESSAGE_POLL_VOTE_REMOVE" EventTypeMessageReactionAdd EventType = "MESSAGE_REACTION_ADD" EventTypeMessageReactionRemove EventType = "MESSAGE_REACTION_REMOVE" EventTypeMessageReactionRemoveAll EventType = "MESSAGE_REACTION_REMOVE_ALL" EventTypeMessageReactionRemoveEmoji EventType = "MESSAGE_REACTION_REMOVE_EMOJI" EventTypePresenceUpdate EventType = "PRESENCE_UPDATE" EventTypeSoundboardSounds EventType = "SOUNDBOARD_SOUNDS" EventTypeStageInstanceCreate EventType = "STAGE_INSTANCE_CREATE" EventTypeStageInstanceDelete EventType = "STAGE_INSTANCE_DELETE" EventTypeStageInstanceUpdate EventType = "STAGE_INSTANCE_UPDATE" EventTypeSubscriptionCreate EventType = "SUBSCRIPTION_CREATE" EventTypeSubscriptionUpdate EventType = "SUBSCRIPTION_UPDATE" EventTypeSubscriptionDelete EventType = "SUBSCRIPTION_DELETE" EventTypeTypingStart EventType = "TYPING_START" EventTypeUserUpdate EventType = "USER_UPDATE" EventTypeVoiceChannelEffectSend EventType = "VOICE_CHANNEL_EFFECT_SEND" EventTypeVoiceStateUpdate EventType = "VOICE_STATE_UPDATE" EventTypeVoiceServerUpdate EventType = "VOICE_SERVER_UPDATE" EventTypeWebhooksUpdate EventType = "WEBHOOKS_UPDATE" )
Constants for the gateway events
type EventTypingStart ¶ added in v0.13.0
type EventTypingStart struct {
ChannelID snowflake.ID `json:"channel_id"`
GuildID *snowflake.ID `json:"guild_id,omitempty"`
UserID snowflake.ID `json:"user_id"`
Timestamp time.Time `json:"timestamp"`
Member *discord.Member `json:"member,omitempty"`
User discord.User `json:"user"`
}
func (*EventTypingStart) UnmarshalJSON ¶ added in v0.13.0
func (e *EventTypingStart) UnmarshalJSON(data []byte) error
type EventUnknown ¶ added in v0.15.0
type EventUnknown json.RawMessage
EventUnknown is an event that is not known to disgo
func (EventUnknown) MarshalJSON ¶ added in v0.15.0
func (e EventUnknown) MarshalJSON() ([]byte, error)
func (*EventUnknown) UnmarshalJSON ¶ added in v0.15.0
func (e *EventUnknown) UnmarshalJSON(data []byte) error
type EventUserUpdate ¶ added in v0.13.0
type EventUserUpdate struct {
discord.OAuth2User
}
type EventVoiceChannelEffectSend ¶ added in v0.18.11
type EventVoiceChannelEffectSend struct {
ChannelID snowflake.ID `json:"channel_id"`
GuildID snowflake.ID `json:"guild_id"`
UserID snowflake.ID `json:"user_id"`
Emoji *discord.Emoji `json:"emoji"`
AnimationType *discord.VoiceChannelEffectAnimationType `json:"animation_type,omitempty"`
AnimationID *int `json:"animation_id,omitempty"`
SoundID *int64 `json:"-"`
SoundVolume *float64 `json:"sound_volume,omitempty"`
}
func (*EventVoiceChannelEffectSend) UnmarshalJSON ¶ added in v0.18.11
func (e *EventVoiceChannelEffectSend) UnmarshalJSON(data []byte) error
type EventVoiceServerUpdate ¶ added in v0.13.0
type EventVoiceStateUpdate ¶ added in v0.13.0
type EventVoiceStateUpdate struct {
discord.VoiceState
Member discord.Member `json:"member"`
}
type EventWebhooksUpdate ¶ added in v0.13.0
type Gateway ¶
type Gateway interface {
// ShardID returns the shard ID that this Gateway is configured to use.
ShardID() int
// ShardCount returns the total number of shards that this Gateway is configured to use.
ShardCount() int
// SessionID returns the session ID that is used by this Gateway.
// This may be nil if the Gateway was never connected to Discord, was gracefully closed with websocket.CloseNormalClosure or websocket.CloseGoingAway.
SessionID() *string
// LastSequenceReceived returns the last sequence number that was received by the Gateway.
// This may be nil if the Gateway was never connected to Discord, was gracefully closed with websocket.CloseNormalClosure or websocket.CloseGoingAway.
LastSequenceReceived() *int
// ResumeURL returns the resume url that was received by the Gateway
ResumeURL() *string
// Intents returns the Intents that are used by this Gateway.
Intents() Intents
// Open connects this Gateway to the Discord API.
Open(ctx context.Context) error
// Close gracefully closes the Gateway with the websocket.CloseNormalClosure code.
// If the context is done, the Gateway connection will be killed.
Close(ctx context.Context)
// CloseWithCode closes the Gateway with the given code & message.
// If the context is done, the Gateway connection will be killed.
CloseWithCode(ctx context.Context, code int, message string)
// Status returns the Status of the Gateway.
Status() Status
// Send sends a message to the Discord gateway with the opCode and data.
// If context is deadline exceeds, the message sending will be aborted.
Send(ctx context.Context, op Opcode, data MessageData) error
// Latency returns the latency of the Gateway.
// This is calculated by the time it takes to send a heartbeat and receive a heartbeat ack by discord.
Latency() time.Duration
// Presence returns the current presence of the Gateway.
Presence() *MessageDataPresenceUpdate
}
Gateway is what is used to connect to discord.
type IdentifyCommandDataProperties ¶ added in v0.13.0
type IdentifyCommandDataProperties struct {
OS string `json:"os"` // user OS
Browser string `json:"browser"` // library name
Device string `json:"device"` // library name
}
IdentifyCommandDataProperties is used for specifying to discord which library and OS the bot is using, is automatically handled by the library and should rarely be used.
type IdentifyRateLimiter ¶ added in v0.19.0
type IdentifyRateLimiter interface {
// Close gracefully closes the RateLimiter.
// If the context deadline is exceeded, the RateLimiter will be closed immediately.
Close(ctx context.Context)
// Wait waits for the given shardID bucket to be available for new logins.
// If the context deadline is exceeded, Wait will return immediately and no login will be attempted.
Wait(ctx context.Context, shardID int) error
// Unlock unlocks the given shardID bucket.
// If Wait fails, Unlock should not be called.
Unlock(shardID int)
}
IdentifyRateLimiter limits how many shards can log in to Discord at the same time.
func NewIdentifyRateLimiter ¶ added in v0.19.0
func NewIdentifyRateLimiter(opts ...IdentifyRateLimiterConfigOpt) IdentifyRateLimiter
NewIdentifyRateLimiter creates a new default RateLimiter with the given IdentifyRateLimiterConfigOpt(s).
func NewNoopIdentifyRateLimiter ¶ added in v0.19.0
func NewNoopIdentifyRateLimiter() IdentifyRateLimiter
NewNoopIdentifyRateLimiter creates a new noop RateLimiter.
type IdentifyRateLimiterConfigOpt ¶ added in v0.19.0
type IdentifyRateLimiterConfigOpt func(config *identifyRateLimiterConfig)
IdentifyRateLimiterConfigOpt is a type alias for a function that takes a identifyRateLimiterConfig and is used to configure your Server.
func WithIdentifyMaxConcurrency ¶ added in v0.19.0
func WithIdentifyMaxConcurrency(maxConcurrency int) IdentifyRateLimiterConfigOpt
WithIdentifyMaxConcurrency sets the maximum number of concurrent identifies allowed per window duration (default is 5 seconds, configurable via WithIdentifyWait).
func WithIdentifyRateLimiterLogger ¶ added in v0.19.0
func WithIdentifyRateLimiterLogger(logger *slog.Logger) IdentifyRateLimiterConfigOpt
WithIdentifyRateLimiterLogger sets the logger for the RateLimiter.
func WithIdentifyWait ¶ added in v0.19.0
func WithIdentifyWait(identifyWait time.Duration) IdentifyRateLimiterConfigOpt
WithIdentifyWait sets the duration to wait in between identifying shards.
type Intents ¶ added in v0.13.0
type Intents int64
Intents is an extension of the Bit structure used when identifying with discord
const ( IntentGuilds Intents = 1 << iota IntentGuildMembers IntentGuildModeration IntentGuildExpressions IntentGuildIntegrations IntentGuildWebhooks IntentGuildInvites IntentGuildVoiceStates IntentGuildPresences IntentGuildMessages IntentGuildMessageReactions IntentGuildMessageTyping IntentDirectMessages IntentDirectMessageReactions IntentDirectMessageTyping IntentMessageContent IntentGuildScheduledEvents IntentAutoModerationConfiguration IntentAutoModerationExecution IntentGuildMessagePolls IntentDirectMessagePolls IntentsGuild = IntentGuilds | IntentGuildMembers | IntentGuildModeration | IntentGuildExpressions | IntentGuildIntegrations | IntentGuildWebhooks | IntentGuildInvites | IntentGuildVoiceStates | IntentGuildPresences | IntentGuildMessages | IntentGuildMessageReactions | IntentGuildMessageTyping | IntentGuildScheduledEvents | IntentGuildMessagePolls IntentsDirectMessage = IntentDirectMessages | IntentDirectMessageReactions | IntentDirectMessageTyping | IntentDirectMessagePolls IntentsMessagePolls = IntentGuildMessagePolls | IntentDirectMessagePolls IntentsNonPrivileged = IntentGuilds | IntentGuildModeration | IntentGuildExpressions | IntentGuildIntegrations | IntentGuildWebhooks | IntentGuildInvites | IntentGuildVoiceStates | IntentGuildMessages | IntentGuildMessageReactions | IntentGuildMessageTyping | IntentDirectMessages | IntentDirectMessageReactions | IntentDirectMessageTyping | IntentGuildScheduledEvents | IntentAutoModerationConfiguration | IntentAutoModerationExecution | IntentGuildMessagePolls | IntentDirectMessagePolls IntentsPrivileged = IntentGuildMembers | IntentGuildPresences | IntentMessageContent IntentsAll = IntentsNonPrivileged | IntentsPrivileged IntentsDefault = IntentsNone IntentsNone Intents = 0 )
Constants for the different bit offsets of Intents
func (Intents) Add ¶ added in v0.13.0
Add allows you to add multiple bits together, producing a new bit
type Message ¶ added in v0.13.0
type Message struct {
Op Opcode `json:"op"`
S int `json:"s,omitempty"`
T EventType `json:"t,omitempty"`
D MessageData `json:"d,omitempty"`
RawD json.RawMessage `json:"-"`
}
Message raw Message type
func (*Message) UnmarshalJSON ¶ added in v0.13.0
type MessageData ¶ added in v0.13.0
type MessageData interface {
// contains filtered or unexported methods
}
MessageData is the interface for all message data types
type MessageDataHeartbeat ¶ added in v0.13.0
type MessageDataHeartbeat int
MessageDataHeartbeat is used to ensure the websocket connection remains open, and disconnect if not.
func (MessageDataHeartbeat) MarshalJSON ¶ added in v0.18.16
func (m MessageDataHeartbeat) MarshalJSON() ([]byte, error)
type MessageDataHeartbeatACK ¶ added in v0.19.0
type MessageDataHeartbeatACK struct{}
type MessageDataHello ¶ added in v0.13.0
type MessageDataHello struct {
HeartbeatInterval int `json:"heartbeat_interval"`
}
type MessageDataIdentify ¶ added in v0.13.0
type MessageDataIdentify struct {
Token string `json:"token"`
Properties IdentifyCommandDataProperties `json:"properties"`
Compress bool `json:"compress,omitempty"`
LargeThreshold int `json:"large_threshold,omitempty"`
Shard *[2]int `json:"shard,omitempty"`
Intents Intents `json:"intents"`
Presence *MessageDataPresenceUpdate `json:"presence,omitempty"`
}
MessageDataIdentify is the data used in IdentifyCommandData
type MessageDataInvalidSession ¶ added in v0.13.0
type MessageDataInvalidSession bool
type MessageDataPresenceUpdate ¶ added in v0.13.0
type MessageDataPresenceUpdate struct {
Since *int64 `json:"since"`
Activities []discord.Activity `json:"activities"`
Status discord.OnlineStatus `json:"status"`
AFK bool `json:"afk"`
}
MessageDataPresenceUpdate is used for updating Client's presence
type MessageDataReconnect ¶ added in v0.19.0
type MessageDataReconnect struct{}
type MessageDataRequestGuildMembers ¶ added in v0.13.0
type MessageDataRequestGuildMembers struct {
GuildID snowflake.ID `json:"guild_id"`
Query *string `json:"query,omitempty"` // If specified, user_ids must not be entered
Limit *int `json:"limit,omitempty"` // Must be >=1 if query/user_ids is used, otherwise 0
Presences bool `json:"presences,omitempty"`
UserIDs []snowflake.ID `json:"user_ids,omitempty"` // If specified, query must not be entered
Nonce string `json:"nonce,omitempty"` // All responses are hashed with this nonce, optional
}
MessageDataRequestGuildMembers is used for fetching all the members of a guild_events. It is recommended you have a strict member caching policy when using this.
type MessageDataRequestSoundboardSounds ¶ added in v0.18.13
type MessageDataResume ¶ added in v0.13.0
type MessageDataResume struct {
Token string `json:"token"`
SessionID string `json:"session_id"`
Seq int `json:"seq"`
}
MessageDataResume is used to resume a connection to discord in the case that you are disconnected. Is automatically handled by the library and should rarely be used.
type MessageDataUnknown ¶ added in v0.15.0
type MessageDataUnknown json.RawMessage
type MessageDataVoiceStateUpdate ¶ added in v0.13.0
type MessageDataVoiceStateUpdate struct {
GuildID snowflake.ID `json:"guild_id"`
ChannelID *snowflake.ID `json:"channel_id"`
SelfMute bool `json:"self_mute"`
SelfDeaf bool `json:"self_deaf"`
}
MessageDataVoiceStateUpdate is used for updating the bots voice state in a guild
type Opcode ¶ added in v0.13.0
type Opcode int
Opcode are opcodes used by discord
const ( OpcodeDispatch Opcode = iota OpcodeHeartbeat OpcodeIdentify OpcodePresenceUpdate OpcodeVoiceStateUpdate OpcodeResume OpcodeReconnect OpcodeRequestGuildMembers OpcodeInvalidSession OpcodeHello OpcodeHeartbeatACK OpcodeRequestSoundboardSounds Opcode = 31 )
https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes
type PresenceOpt ¶ added in v0.13.19
type PresenceOpt func(presenceUpdate *MessageDataPresenceUpdate)
func WithAfk ¶ added in v0.13.19
func WithAfk(afk bool) PresenceOpt
WithAfk sets whether the session is afk
func WithCompetingActivity ¶ added in v0.13.19
func WithCompetingActivity(name string, opts ...ActivityOpt) PresenceOpt
WithCompetingActivity creates a new "Competing in ..." activity of type discord.ActivityTypeCompeting
func WithCustomActivity ¶ added in v0.16.9
func WithCustomActivity(status string, opts ...ActivityOpt) PresenceOpt
WithCustomActivity creates a new activity of type discord.ActivityTypeCustom
func WithListeningActivity ¶ added in v0.13.19
func WithListeningActivity(name string, opts ...ActivityOpt) PresenceOpt
WithListeningActivity creates a new "Listening to ..." activity of type discord.ActivityTypeListening
func WithOnlineStatus ¶ added in v0.13.19
func WithOnlineStatus(status discord.OnlineStatus) PresenceOpt
WithOnlineStatus sets the online status to the provided discord.OnlineStatus
func WithPlayingActivity ¶ added in v0.13.19
func WithPlayingActivity(name string, opts ...ActivityOpt) PresenceOpt
WithPlayingActivity creates a new "Playing ..." activity of type discord.ActivityTypeGame
func WithSince ¶ added in v0.13.19
func WithSince(since *int64) PresenceOpt
WithSince sets when the session has gone afk
func WithStreamingActivity ¶ added in v0.13.19
func WithStreamingActivity(name string, url string, opts ...ActivityOpt) PresenceOpt
WithStreamingActivity creates a new "Streaming ..." activity of type discord.ActivityTypeStreaming
func WithWatchingActivity ¶ added in v0.13.19
func WithWatchingActivity(name string, opts ...ActivityOpt) PresenceOpt
WithWatchingActivity creates a new "Watching ..." activity of type discord.ActivityTypeWatching
type RateLimitedMetadata ¶ added in v0.19.0
type RateLimitedMetadata interface {
// contains filtered or unexported methods
}
RateLimitedMetadata is an interface for all ratelimited metadatas. RateLimitedMetadataRequestGuildMembers RateLimitedMetadataUnknown
type RateLimitedMetadataRequestGuildMembers ¶ added in v0.19.0
type RateLimitedMetadataUnknown ¶ added in v0.19.0
type RateLimitedMetadataUnknown json.RawMessage
type RateLimiter ¶ added in v0.12.0
type RateLimiter interface {
// Close gracefully closes the RateLimiter.
// If the context deadline is exceeded, the RateLimiter will be closed immediately.
Close(ctx context.Context)
// Reset resets the RateLimiter to its initial state.
Reset()
// Wait waits for the RateLimiter to be ready to send a new message.
// If the context deadline is exceeded, Wait will return immediately and no message will be sent.
Wait(ctx context.Context, commandType RateLimiterCommandType) error
// Unlock unlocks the RateLimiter and allows the next message to be sent.
Unlock()
}
RateLimiter provides handles the rate limiting logic for connecting to Discord's Gateway.
func NewRateLimiter ¶ added in v0.12.0
func NewRateLimiter(opts ...RateLimiterConfigOpt) RateLimiter
NewRateLimiter creates a new default RateLimiter with the given RateLimiterConfigOpt(s).
type RateLimiterCommandType ¶ added in v0.19.0
type RateLimiterCommandType int
RateLimiterCommandType represents the type of wait performed by the rate-limiter
const ( NormalCommandType RateLimiterCommandType = iota InternalCommandType )
type RateLimiterConfigOpt ¶ added in v0.12.0
type RateLimiterConfigOpt func(config *rateLimiterConfig)
RateLimiterConfigOpt is a type alias for a function that takes a rateLimiterConfig and is used to configure your Server.
func WithCommandsPerMinute ¶ added in v0.12.0
func WithCommandsPerMinute(commandsPerMinute int) RateLimiterConfigOpt
WithCommandsPerMinute sets the number of commands per minute that the Gateway will allow.
func WithRateLimiterLogger ¶ added in v0.12.0
func WithRateLimiterLogger(logger *slog.Logger) RateLimiterConfigOpt
WithRateLimiterLogger sets the Logger for the Gateway.
func WithReservedCommandSlots ¶ added in v0.19.0
func WithReservedCommandSlots(reservedCommandSlots int) RateLimiterConfigOpt
WithReservedCommandSlots sets the number of reserved slots for Gateway priority events, like heartbeats.
type Status ¶
type Status int
Status is the state that the client is currently in.
const ( // StatusUnconnected is the initial state when a new Gateway is created. StatusUnconnected Status = iota // StatusConnecting is the state when the client is connecting to the Discord gateway. StatusConnecting // StatusWaitingForHello is the state when the Gateway is waiting for the first OpcodeHello packet. StatusWaitingForHello // StatusIdentifying is the state when the Gateway received its first OpcodeHello packet and now sends a OpcodeIdentify packet. StatusIdentifying // StatusResuming is the state when the Gateway received its first OpcodeHello packet and now sends a OpcodeResume packet. StatusResuming // StatusWaitingForReady is the state when the Gateway received sent a OpcodeIdentify or OpcodeResume packet and now waits for a OpcodeDispatch with EventTypeReady packet. StatusWaitingForReady // StatusReady is the state when the Gateway received a OpcodeDispatch with EventTypeReady packet. StatusReady // StatusDisconnected is the state when the Gateway is disconnected. // Either due to an error or because the Gateway was closed gracefully. StatusDisconnected )
Indicates how far along the client is too connecting.
func (Status) IsConnected ¶
IsConnected returns whether the Gateway is connected.