Documentation
¶
Index ¶
- Constants
- func AttachmentURL(channelID, attachmentID, filename string) string
- func BuildAcceptLanguage(locale string) string
- func DefaultUserAvatarURL(index int, size int) string
- func EmojiURL(emojiID string, animated bool, format string) string
- func GuildBannerURL(guildID, bannerHash string, size int, format string, animated bool) string
- func GuildIconURL(guildID, iconHash string, size int, format string, animated bool) string
- func GuildSplashURL(guildID, splashHash string, size int, format string) string
- func LogEventHandlerExample(ws *DiscordWebSocket)
- func UserAvatarURL(userID, avatarHash string, size int, format string, animated bool) string
- func UserBannerURL(userID, bannerHash string, size int, format string, animated bool) string
- type Activity
- type ArchivedThreadsOptions
- type AuthSessionChangeEvent
- type AutoModerationAction
- type AutoModerationActionMetadata
- type AutoModerationEvent
- type BrowserClient
- func (c *BrowserClient) AddReaction(ctx context.Context, channelID, messageID string, emoji interface{}) error
- func (c *BrowserClient) BulkSubscribeToGuilds(subscriptions map[string]GuildSubscribeOptions) error
- func (c *BrowserClient) Close() error
- func (c *BrowserClient) ConnectWebSocket(ctx context.Context) error
- func (c *BrowserClient) DownloadCDN(ctx context.Context, assetURL string) ([]byte, string, error)
- func (c *BrowserClient) GetActiveThreads(ctx context.Context, guildID string) (*ThreadListResponse, error)
- func (c *BrowserClient) GetAllMessages(ctx context.Context, channelID string, opts *GetAllMessagesOptions) ([]*Message, error)
- func (c *BrowserClient) GetChannel(ctx context.Context, channelID string) (*Channel, error)
- func (c *BrowserClient) GetChannelMessageCount(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (int, error)
- func (c *BrowserClient) GetCurrentUser(ctx context.Context) (*User, error)
- func (c *BrowserClient) GetGuild(ctx context.Context, guildID string) (*Guild, error)
- func (c *BrowserClient) GetGuildChannels(ctx context.Context, guildID string) ([]*Channel, error)
- func (c *BrowserClient) GetGuildEmojis(ctx context.Context, guildID string) ([]*Emoji, error)
- func (c *BrowserClient) GetGuildMemberCount(ctx context.Context, guildID string) (int, error)
- func (c *BrowserClient) GetGuildMembers(ctx context.Context, guildID string, limit int) ([]*GuildMember, error)
- func (c *BrowserClient) GetGuilds(ctx context.Context) ([]*Guild, error)
- func (c *BrowserClient) GetJoinedPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
- func (c *BrowserClient) GetLatestAttachmentData(ctx context.Context, channelID string) ([]byte, string, string, error)
- func (c *BrowserClient) GetLatestAttachmentURL(ctx context.Context, channelID string) (string, error)
- func (c *BrowserClient) GetMessage(ctx context.Context, channelID, messageID string) (*Message, error)
- func (c *BrowserClient) GetMessageThread(ctx context.Context, channelID, messageID string) (*Thread, error)
- func (c *BrowserClient) GetMessages(ctx context.Context, channelID string, opts *GetMessagesOptions) ([]*Message, error)
- func (c *BrowserClient) GetPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
- func (c *BrowserClient) GetPublicArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
- func (c *BrowserClient) GuildName(guildID string) string
- func (c *BrowserClient) Initialize(ctx context.Context) error
- func (c *BrowserClient) JoinGuild(ctx context.Context, inviteCode string) error
- func (c *BrowserClient) ListenForEvents(ctx context.Context, eventHandler EventHandler) error
- func (c *BrowserClient) SearchMessages(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (*MessageSearchResponse, error)
- func (c *BrowserClient) SendMessage(ctx context.Context, channelID string, content string) (*Message, error)
- func (c *BrowserClient) SetGuildName(guildID, name string)
- func (c *BrowserClient) SubscribeToAllGuildFeatures(guildID string) error
- func (c *BrowserClient) SubscribeToGuild(guildID string, options GuildSubscribeOptions) error
- func (c *BrowserClient) SubscribeToGuildChannels(guildID string, channels map[string][][]int) error
- func (c *BrowserClient) SubscribeToGuildMembers(guildID string, memberIDs []string) error
- func (c *BrowserClient) SubscribeToGuildThreads(guildID string, threadIDs []string) error
- func (c *BrowserClient) UnsubscribeFromGuild(guildID string) error
- func (c *BrowserClient) UpdateStatus(ctx context.Context, status string, game *Game, afk bool, since int64) error
- type BulkGuildSubscribePayload
- type CallEvent
- type Channel
- type ChannelPinsAckEvent
- type ClientInfo
- type ClientStatePayload
- type ClientStatus
- type Config
- type ConnectionEvent
- type ConversationSummary
- type ConversationSummaryUpdateEvent
- type DiscordClient
- type DiscordWebSocket
- func (ws *DiscordWebSocket) AddChannelCreateHandler(handler func(*Channel) error)
- func (ws *DiscordWebSocket) AddChannelDeleteHandler(handler func(*Channel) error)
- func (ws *DiscordWebSocket) AddChannelUpdateHandler(handler func(*Channel) error)
- func (ws *DiscordWebSocket) AddConversationSummaryUpdateHandler(handler func(*ConversationSummaryUpdateEvent) error)
- func (ws *DiscordWebSocket) AddEventHandler(eventType string, handler EventHandler)
- func (ws *DiscordWebSocket) AddGuildCreateHandler(handler func(*Guild) error)
- func (ws *DiscordWebSocket) AddGuildDeleteHandler(handler func(*GuildDeleteEvent) error)
- func (ws *DiscordWebSocket) AddGuildMemberAddHandler(handler func(*GuildMemberEvent) error)
- func (ws *DiscordWebSocket) AddGuildScheduledEventUserAddHandler(handler func(*GuildScheduledEventUserEvent) error)
- func (ws *DiscordWebSocket) AddGuildScheduledEventUserRemoveHandler(handler func(*GuildScheduledEventUserEvent) error)
- func (ws *DiscordWebSocket) AddGuildUpdateHandler(handler func(*Guild) error)
- func (ws *DiscordWebSocket) AddMessageCreateHandler(handler func(*Message) error)
- func (ws *DiscordWebSocket) AddMessageDeleteHandler(handler func(*MessageDeleteEvent) error)
- func (ws *DiscordWebSocket) AddMessageReactionAddHandler(handler func(*MessageReactionEvent) error)
- func (ws *DiscordWebSocket) AddMessageReactionAddManyHandler(handler func(*MessageReactionAddManyEvent) error)
- func (ws *DiscordWebSocket) AddMessageReactionRemoveHandler(handler func(*MessageReactionEvent) error)
- func (ws *DiscordWebSocket) AddMessageUpdateHandler(handler func(*Message) error)
- func (ws *DiscordWebSocket) AddTestEventHandler(handler func(*TestEvent) error)
- func (ws *DiscordWebSocket) AddThreadCreateHandler(handler func(*ThreadEvent) error)
- func (ws *DiscordWebSocket) AddThreadDeleteHandler(handler func(*ThreadDeleteEvent) error)
- func (ws *DiscordWebSocket) AddThreadListSyncHandler(handler func(*ThreadListSyncEvent) error)
- func (ws *DiscordWebSocket) AddThreadMemberListUpdateHandler(handler func(*ThreadMemberListUpdateEvent) error)
- func (ws *DiscordWebSocket) AddThreadMemberUpdateHandler(handler func(*ThreadMemberUpdateEvent) error)
- func (ws *DiscordWebSocket) AddThreadMembersUpdateHandler(handler func(*ThreadMembersUpdateEvent) error)
- func (ws *DiscordWebSocket) AddThreadUpdateHandler(handler func(*ThreadEvent) error)
- func (ws *DiscordWebSocket) AddTypingStartHandler(handler func(*TypingStartEvent) error)
- func (ws *DiscordWebSocket) AddUserUpdateHandler(handler func(*User) error)
- func (ws *DiscordWebSocket) AddVoiceStateUpdateHandler(handler func(*VoiceState) error)
- func (ws *DiscordWebSocket) BulkSubscribeToGuilds(subscriptions map[string]GuildSubscribeOptions) error
- func (ws *DiscordWebSocket) Close() error
- func (ws *DiscordWebSocket) Connect(ctx context.Context) error
- func (ws *DiscordWebSocket) EnableAllEventLogging()
- func (ws *DiscordWebSocket) GuildName(guildID string) string
- func (ws *DiscordWebSocket) IsConnected() bool
- func (ws *DiscordWebSocket) SendMessage(op int, data interface{}) error
- func (ws *DiscordWebSocket) SetGuildName(guildID, name string)
- func (ws *DiscordWebSocket) SubscribeToAllGuildFeatures(guildID string) error
- func (ws *DiscordWebSocket) SubscribeToGuild(guildID string, options GuildSubscribeOptions) error
- func (ws *DiscordWebSocket) SubscribeToGuildChannels(guildID string, channels map[string][][]int) error
- func (ws *DiscordWebSocket) SubscribeToGuildMembers(guildID string, memberIDs []string) error
- func (ws *DiscordWebSocket) SubscribeToGuildThreads(guildID string, threadIDs []string) error
- func (ws *DiscordWebSocket) UnsubscribeFromGuild(guildID string) error
- type EmbeddedActivity
- type Emoji
- type EmojiReaction
- type EventHandler
- type FriendSuggestionEvent
- type Game
- type GatewayEvent
- type GatewayMessageEvent
- type GatewayPayload
- type GatewayReadyEvent
- type GetAllMessagesOptions
- type GetMessagesOptions
- type Guild
- type GuildDeleteEvent
- type GuildMember
- type GuildMemberEvent
- type GuildMemberListGroup
- type GuildMemberListOP
- type GuildMemberListUpdateEvent
- type GuildScheduledEvent
- type GuildScheduledEventUserEvent
- type GuildSubscribeOptions
- type GuildSubscribePayload
- type HelloPayload
- type IdentifyPayload
- type InviteEvent
- type Member
- type MergedMembers
- type MergedPresences
- type Message
- type MessageAckEvent
- type MessageCache
- type MessageDeleteEvent
- type MessageReactionAddManyEvent
- type MessageReactionEvent
- type MessageReactionManyItem
- type MessageSearchOptions
- type MessageSearchResponse
- type Mode
- type PartialUpdateChannel
- type PassiveUpdateV1Event
- type PassiveUpdateV2Event
- type PaymentUpdateEvent
- type PresencePayload
- type PresenceUpdateEvent
- type ProgressInfo
- type RateLimitResponse
- type RateLimiter
- type ReadyPayload
- type ReadySupplementalEvent
- type ResumePayload
- type Session
- type SessionsReplaceEvent
- type StickerItem
- type SuperProperties
- type SupplementalGuild
- type TLSClient
- func (c *TLSClient) AddReaction(ctx context.Context, channelID, messageID string, emoji interface{}) error
- func (c *TLSClient) BulkSubscribeToGuilds(subscriptions map[string]GuildSubscribeOptions) error
- func (c *TLSClient) Close() error
- func (c *TLSClient) ConnectWebSocket(ctx context.Context) error
- func (c *TLSClient) DownloadCDN(ctx context.Context, assetURL string) ([]byte, string, error)
- func (c *TLSClient) GetActiveThreads(ctx context.Context, guildID string) (*ThreadListResponse, error)
- func (c *TLSClient) GetAllMessages(ctx context.Context, channelID string, opts *GetAllMessagesOptions) ([]*Message, error)
- func (c *TLSClient) GetChannel(ctx context.Context, channelID string) (*Channel, error)
- func (c *TLSClient) GetChannelMessageCount(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (int, error)
- func (c *TLSClient) GetCurrentUser(ctx context.Context) (*User, error)
- func (c *TLSClient) GetGuild(ctx context.Context, guildID string) (*Guild, error)
- func (c *TLSClient) GetGuildChannels(ctx context.Context, guildID string) ([]*Channel, error)
- func (c *TLSClient) GetGuildEmojis(ctx context.Context, guildID string) ([]*Emoji, error)
- func (c *TLSClient) GetGuildMemberCount(ctx context.Context, guildID string) (int, error)
- func (c *TLSClient) GetGuildMembers(ctx context.Context, guildID string, limit int) ([]*GuildMember, error)
- func (c *TLSClient) GetGuilds(ctx context.Context) ([]*Guild, error)
- func (c *TLSClient) GetJoinedPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
- func (c *TLSClient) GetLatestAttachmentData(ctx context.Context, channelID string) ([]byte, string, string, error)
- func (c *TLSClient) GetLatestAttachmentURL(ctx context.Context, channelID string) (string, error)
- func (c *TLSClient) GetMessage(ctx context.Context, channelID, messageID string) (*Message, error)
- func (c *TLSClient) GetMessageThread(ctx context.Context, channelID, messageID string) (*Thread, error)
- func (c *TLSClient) GetMessages(ctx context.Context, channelID string, opts *GetMessagesOptions) ([]*Message, error)
- func (c *TLSClient) GetPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
- func (c *TLSClient) GetPublicArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
- func (c *TLSClient) GuildName(guildID string) string
- func (c *TLSClient) Initialize(ctx context.Context) error
- func (c *TLSClient) IsConnected() bool
- func (c *TLSClient) JoinGuild(ctx context.Context, inviteCode string) error
- func (c *TLSClient) ListenForEvents(ctx context.Context, eventHandler EventHandler) error
- func (c *TLSClient) SearchMessages(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (*MessageSearchResponse, error)
- func (c *TLSClient) SendMessage(ctx context.Context, channelID string, content string) (*Message, error)
- func (c *TLSClient) SetGuildName(guildID, name string)
- func (c *TLSClient) SubscribeToAllGuildFeatures(guildID string) error
- func (c *TLSClient) SubscribeToGuild(guildID string, options GuildSubscribeOptions) error
- func (c *TLSClient) SubscribeToGuildChannels(guildID string, channels map[string][][]int) error
- func (c *TLSClient) SubscribeToGuildMembers(guildID string, memberIDs []string) error
- func (c *TLSClient) SubscribeToGuildThreads(guildID string, threadIDs []string) error
- func (c *TLSClient) UnsubscribeFromGuild(guildID string) error
- func (c *TLSClient) UpdateStatus(ctx context.Context, status string, game *Game, afk bool, since int64) error
- type TestEvent
- type Thread
- type ThreadDeleteEvent
- type ThreadEvent
- type ThreadListResponse
- type ThreadListSyncEvent
- type ThreadMember
- type ThreadMemberListUpdateEvent
- type ThreadMemberUpdateEvent
- type ThreadMembersUpdateEvent
- type ThreadMetadata
- type TypingStartEvent
- type User
- type UserNoteUpdateEvent
- type VoiceState
- type VoiceStateEvent
- type WebSocketEvent
- type WebSocketMessageEvent
- type WebSocketRateLimiter
- type WebSocketReactionEvent
- type WebSocketReadyEvent
- type WebSocketRelationshipEvent
- type WebSocketTypingEvent
- type WebSocketVoiceStateEvent
Constants ¶
const ( // Authentication & Connection EventReady = "READY" EventResumed = "RESUMED" EventReadySupplemental = "READY_SUPPLEMENTAL" EventSessionsReplace = "SESSIONS_REPLACE" // Guild Events EventGuildCreate = "GUILD_CREATE" EventGuildDelete = "GUILD_DELETE" EventGuildUpdate = "GUILD_UPDATE" EventGuildMemberAdd = "GUILD_MEMBER_ADD" EventGuildMemberRemove = "GUILD_MEMBER_REMOVE" EventGuildMemberUpdate = "GUILD_MEMBER_UPDATE" EventGuildMembersChunk = "GUILD_MEMBERS_CHUNK" EventGuildMemberListUpdate = "GUILD_MEMBER_LIST_UPDATE" EventGuildRoleCreate = "GUILD_ROLE_CREATE" EventGuildRoleDelete = "GUILD_ROLE_DELETE" EventGuildRoleUpdate = "GUILD_ROLE_UPDATE" EventGuildBanAdd = "GUILD_BAN_ADD" EventGuildBanRemove = "GUILD_BAN_REMOVE" EventGuildEmojisUpdate = "GUILD_EMOJIS_UPDATE" EventGuildStickersUpdate = "GUILD_STICKERS_UPDATE" EventGuildApplicationCommandUpdate = "GUILD_APPLICATION_COMMAND_INDEX_UPDATE" // Channel Events EventChannelCreate = "CHANNEL_CREATE" EventChannelDelete = "CHANNEL_DELETE" EventChannelUpdate = "CHANNEL_UPDATE" EventChannelPinsUpdate = "CHANNEL_PINS_UPDATE" EventChannelPinsAck = "CHANNEL_PINS_ACK" EventChannelRecipientAdd = "CHANNEL_RECIPIENT_ADD" EventChannelRecipientRemove = "CHANNEL_RECIPIENT_REMOVE" // Message Events EventMessageCreate = "MESSAGE_CREATE" EventMessageDelete = "MESSAGE_DELETE" EventMessageUpdate = "MESSAGE_UPDATE" EventMessageDeleteBulk = "MESSAGE_DELETE_BULK" EventMessageReactionAdd = "MESSAGE_REACTION_ADD" EventMessageReactionRemove = "MESSAGE_REACTION_REMOVE" EventMessageReactionRemoveAll = "MESSAGE_REACTION_REMOVE_ALL" EventMessageReactionRemoveEmoji = "MESSAGE_REACTION_REMOVE_EMOJI" EventMessageReactionAddMany = "MESSAGE_REACTION_ADD_MANY" EventMessagePollVoteAdd = "MESSAGE_POLL_VOTE_ADD" EventMessagePollVoteRemove = "MESSAGE_POLL_VOTE_REMOVE" EventMessageAck = "MESSAGE_ACK" // Thread Events EventThreadCreate = "THREAD_CREATE" EventThreadDelete = "THREAD_DELETE" EventThreadUpdate = "THREAD_UPDATE" EventThreadListSync = "THREAD_LIST_SYNC" EventThreadMemberUpdate = "THREAD_MEMBER_UPDATE" EventThreadMembersUpdate = "THREAD_MEMBERS_UPDATE" EventThreadMemberListUpdate = "THREAD_MEMBER_LIST_UPDATE" // User & Presence EventUserUpdate = "USER_UPDATE" EventPresenceUpdate = "PRESENCE_UPDATE" EventTypingStart = "TYPING_START" EventRelationshipAdd = "RELATIONSHIP_ADD" EventRelationshipRemove = "RELATIONSHIP_REMOVE" EventRelationshipUpdate = "RELATIONSHIP_UPDATE" EventUserNoteUpdate = "USER_NOTE_UPDATE" // Voice & Calls EventVoiceStateUpdate = "VOICE_STATE_UPDATE" EventVoiceServerUpdate = "VOICE_SERVER_UPDATE" EventCallCreate = "CALL_CREATE" EventCallUpdate = "CALL_UPDATE" EventCallDelete = "CALL_DELETE" EventVoiceChannelEffectSend = "VOICE_CHANNEL_EFFECT_SEND" // Application Commands EventApplicationCommandCreate = "APPLICATION_COMMAND_CREATE" EventApplicationCommandDelete = "APPLICATION_COMMAND_DELETE" EventApplicationCommandUpdate = "APPLICATION_COMMAND_UPDATE" EventApplicationCommandPermissionsUpdate = "APPLICATION_COMMAND_PERMISSIONS_UPDATE" // Moderation EventAutoModerationActionExecution = "AUTO_MODERATION_ACTION_EXECUTION" EventAutoModerationRuleCreate = "AUTO_MODERATION_RULE_CREATE" EventAutoModerationRuleDelete = "AUTO_MODERATION_RULE_DELETE" EventAutoModerationRuleUpdate = "AUTO_MODERATION_RULE_UPDATE" // Integrations & Others EventGuildIntegrationsUpdate = "GUILD_INTEGRATIONS_UPDATE" EventIntegrationCreate = "INTEGRATION_CREATE" EventIntegrationUpdate = "INTEGRATION_UPDATE" EventIntegrationDelete = "INTEGRATION_DELETE" EventInviteCreate = "INVITE_CREATE" EventInviteDelete = "INVITE_DELETE" EventWebhooksUpdate = "WEBHOOKS_UPDATE" EventStageInstanceCreate = "STAGE_INSTANCE_CREATE" EventStageInstanceUpdate = "STAGE_INSTANCE_UPDATE" EventStageInstanceDelete = "STAGE_INSTANCE_DELETE" EventGuildScheduledEventCreate = "GUILD_SCHEDULED_EVENT_CREATE" EventGuildScheduledEventUpdate = "GUILD_SCHEDULED_EVENT_UPDATE" EventGuildScheduledEventDelete = "GUILD_SCHEDULED_EVENT_DELETE" EventGuildScheduledEventUserAdd = "GUILD_SCHEDULED_EVENT_USER_ADD" EventGuildScheduledEventUserRemove = "GUILD_SCHEDULED_EVENT_USER_REMOVE" EventGuildAuditLogEntryCreate = "GUILD_AUDIT_LOG_ENTRY_CREATE" EventInteractionModalCreate = "INTERACTION_MODAL_CREATE" // Additional Events from discord.py-self EventPassiveUpdateV1 = "PASSIVE_UPDATE_V1" EventPassiveUpdateV2 = "PASSIVE_UPDATE_V2" EventFriendSuggestionCreate = "FRIEND_SUGGESTION_CREATE" EventFriendSuggestionDelete = "FRIEND_SUGGESTION_DELETE" EventRecentMentionDelete = "RECENT_MENTION_DELETE" EventAuthSessionChange = "AUTH_SESSION_CHANGE" EventConnectionCreate = "CONNECTION_CREATE" EventConnectionDelete = "CONNECTION_DELETE" EventConnectionUpdate = "CONNECTION_UPDATE" EventPaymentUpdate = "PAYMENT_UPDATE" EventGiftCodeUpdate = "GIFT_CODE_UPDATE" EventEntitlementCreate = "ENTITLEMENT_CREATE" EventEntitlementUpdate = "ENTITLEMENT_UPDATE" EventEntitlementDelete = "ENTITLEMENT_DELETE" EventLibraryApplicationUpdate = "LIBRARY_APPLICATION_UPDATE" EventNonChannelAck = "NON_CHANNEL_ACK" EventDirectoryEntryCreate = "DIRECTORY_ENTRY_CREATE" EventDirectoryEntryUpdate = "DIRECTORY_ENTRY_UPDATE" EventDirectoryEntryDelete = "DIRECTORY_ENTRY_DELETE" // Events from discord-self-test/events directory EventConversationSummaryUpdate = "CONVERSATION_SUMMARY_UPDATE" EventTestEvent = "TEST_EVENT" )
Discord Event Types as documented in discord.py-self
const ( DiscordClientBuildNumber = 352293 DiscordBrowserVersion = "1.0.9198" DiscordOSVersion = "10.0.19045" )
Discord client constants
const ( OpDispatch = 0 // Receive - Event dispatch OpHeartbeat = 1 // Send/Receive - Heartbeat OpIdentify = 2 // Send - Initial authentication OpStatusUpdate = 3 // Send - Presence update OpVoiceStateUpdate = 4 // Send - Voice state OpResume = 6 // Send - Resume session OpReconnect = 7 // Receive - Server requests reconnect OpRequestGuildMembers = 8 // Send - Request guild members OpInvalidSession = 9 // Receive - Invalid session OpHello = 10 // Receive - Initial connection OpHeartbeatAck = 11 // Receive - Heartbeat acknowledgment OpDMUpdate = 13 // Send - DM features request OpGuildSubscriptions = 14 // Send - Guild event subscriptions OpStreamCreate = 18 // Send - Create stream OpStreamDelete = 19 // Send - Delete stream OpStreamWatch = 20 // Send - Watch stream OpSearchRecentMembers = 35 // Send - Search guild members OpGuildSubscriptionsBulk = 37 // Send - Bulk guild subscriptions )
Gateway Opcodes
const ( CloseUnknownError = 4000 CloseUnknownOpcode = 4001 CloseDecodeError = 4002 CloseNotAuthenticated = 4003 CloseAuthenticationFailed = 4004 CloseAlreadyAuthenticated = 4005 CloseInvalidSeq = 4007 CloseRateLimited = 4008 CloseSessionTimedOut = 4009 CloseInvalidShard = 4010 CloseShardingRequired = 4011 CloseInvalidAPIVersion = 4012 CloseInvalidIntents = 4013 CloseDisallowedIntents = 4014 )
Gateway Close Codes
Variables ¶
This section is empty.
Functions ¶
func AttachmentURL ¶
AttachmentURL builds a CDN URL for a message attachment Example: https://cdn.discordapp.com/attachments/{channel_id}/{attachment_id}/{filename}
func BuildAcceptLanguage ¶
BuildAcceptLanguage derives Accept-Language header from locale e.g., "en-US" -> "en-US,en;q=0.5"
func DefaultUserAvatarURL ¶
DefaultUserAvatarURL builds a URL for a default user avatar index [0..5) If discriminator is available (legacy), use int(discriminator) % 5. Otherwise compute id % 6 per Discord docs.
func EmojiURL ¶
EmojiURL builds a CDN URL for a custom emoji Example: https://cdn.discordapp.com/emojis/{emoji_id}.{ext}
func GuildBannerURL ¶
GuildBannerURL builds a CDN URL for a guild banner
func GuildIconURL ¶
GuildIconURL builds a CDN URL for a guild icon Example: https://cdn.discordapp.com/icons/{guild_id}/{icon_hash}.{ext}?size=1024
func GuildSplashURL ¶
GuildSplashURL builds a CDN URL for a guild splash
func LogEventHandlerExample ¶
func LogEventHandlerExample(ws *DiscordWebSocket)
LogEventHandlerExample demonstrates how to use event handlers with logging
func UserAvatarURL ¶
UserAvatarURL builds a CDN URL for a user avatar If avatarHash is empty, you should use DefaultUserAvatarURL with discriminator or user ID modulo 5 Example: https://cdn.discordapp.com/avatars/{user_id}/{avatar_hash}.{ext}?size=1024
func UserBannerURL ¶
UserBannerURL builds a CDN URL for a user banner Example: https://cdn.discordapp.com/banners/{user_id}/{banner_hash}.{ext}?size=2048
Types ¶
type Activity ¶
type Activity struct {
Name string `json:"name"`
Type int `json:"type"`
State string `json:"state,omitempty"`
}
Activity structure
type ArchivedThreadsOptions ¶
type ArchivedThreadsOptions struct {
Before string // Get threads before this timestamp (ISO8601)
Limit int // Number of threads to fetch (default 50)
}
ArchivedThreadsOptions contains options for fetching archived threads
type AuthSessionChangeEvent ¶
type AuthSessionChangeEvent struct {
AuthSessionIDHash string `json:"auth_session_id_hash"`
}
AuthSessionChangeEvent represents auth session changes
type AutoModerationAction ¶
type AutoModerationAction struct {
Type int `json:"type"`
Metadata AutoModerationActionMetadata `json:"metadata,omitempty"`
}
AutoModerationAction represents an auto moderation action
type AutoModerationActionMetadata ¶
type AutoModerationActionMetadata struct {
ChannelID string `json:"channel_id,omitempty"`
DurationSeconds int `json:"duration_seconds,omitempty"`
CustomMessage string `json:"custom_message,omitempty"`
}
AutoModerationActionMetadata represents metadata for auto moderation actions
type AutoModerationEvent ¶
type AutoModerationEvent struct {
GuildID string `json:"guild_id"`
Action AutoModerationAction `json:"action"`
RuleID string `json:"rule_id"`
RuleTriggerType int `json:"rule_trigger_type"`
UserID string `json:"user_id"`
ChannelID string `json:"channel_id,omitempty"`
MessageID string `json:"message_id,omitempty"`
AlertSystemMessageID string `json:"alert_system_message_id,omitempty"`
Content string `json:"content"`
MatchedKeyword string `json:"matched_keyword,omitempty"`
MatchedContent string `json:"matched_content,omitempty"`
}
AutoModerationEvent represents auto moderation events
type BrowserClient ¶
type BrowserClient struct {
// contains filtered or unexported fields
}
BrowserClient implements DiscordClient using rod browser automation
func NewBrowserClient ¶
func NewBrowserClient(config Config) *BrowserClient
NewBrowserClient creates a new browser-based Discord client
func (*BrowserClient) AddReaction ¶
func (c *BrowserClient) AddReaction(ctx context.Context, channelID, messageID string, emoji interface{}) error
AddReaction adds a reaction to a message. The emoji parameter can be:
- A string: Unicode emoji (e.g., "👍") or custom emoji in "name:id" format (e.g., "smile:123456789")
- An *Emoji object: Custom emoji from GetGuildEmojis()
- An EmojiReaction object: Emoji from reaction events
Examples:
- client.AddReaction(ctx, channelID, messageID, "👍")
- client.AddReaction(ctx, channelID, messageID, "smile:123456789")
- emojis, _ := client.GetGuildEmojis(ctx, guildID) client.AddReaction(ctx, channelID, messageID, emojis[0])
func (*BrowserClient) BulkSubscribeToGuilds ¶
func (c *BrowserClient) BulkSubscribeToGuilds(subscriptions map[string]GuildSubscribeOptions) error
BulkSubscribeToGuilds subscribes to multiple guilds at once
func (*BrowserClient) ConnectWebSocket ¶
func (c *BrowserClient) ConnectWebSocket(ctx context.Context) error
ConnectWebSocket establishes a WebSocket connection to Discord's Gateway
func (*BrowserClient) DownloadCDN ¶
DownloadCDN downloads a resource from a Discord CDN URL and returns bytes and content type
func (*BrowserClient) GetActiveThreads ¶
func (c *BrowserClient) GetActiveThreads(ctx context.Context, guildID string) (*ThreadListResponse, error)
GetActiveThreads returns all active threads in a guild
func (*BrowserClient) GetAllMessages ¶
func (c *BrowserClient) GetAllMessages(ctx context.Context, channelID string, opts *GetAllMessagesOptions) ([]*Message, error)
GetAllMessages fetches all messages from a channel with pagination. It mirrors discord.py-self's history() behavior:
- When After is set and OldestFirst is nil, messages are returned oldest->newest
- When Before is set (or neither), messages are returned newest->oldest
- OldestFirst can be explicitly set to override the default ordering
func (*BrowserClient) GetChannel ¶
GetChannel gets channel information
func (*BrowserClient) GetChannelMessageCount ¶
func (c *BrowserClient) GetChannelMessageCount(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (int, error)
GetChannelMessageCount returns the total number of messages in a channel. If guildID is empty, it will be resolved from the channel. If options is nil, defaults are used (no query filter).
func (*BrowserClient) GetCurrentUser ¶
func (c *BrowserClient) GetCurrentUser(ctx context.Context) (*User, error)
GetCurrentUser gets the current user info
func (*BrowserClient) GetGuildChannels ¶
GetGuildChannels gets all channels in a guild
func (*BrowserClient) GetGuildEmojis ¶
GetGuildEmojis gets all emojis in a guild
func (*BrowserClient) GetGuildMemberCount ¶
GetGuildMemberCount gets the number of members in a guild
func (*BrowserClient) GetGuildMembers ¶
func (c *BrowserClient) GetGuildMembers(ctx context.Context, guildID string, limit int) ([]*GuildMember, error)
GetGuildMembers gets members in a guild
func (*BrowserClient) GetGuilds ¶
func (c *BrowserClient) GetGuilds(ctx context.Context) ([]*Guild, error)
GetGuilds gets user's guilds with pagination support
func (*BrowserClient) GetJoinedPrivateArchivedThreads ¶
func (c *BrowserClient) GetJoinedPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
GetJoinedPrivateArchivedThreads returns archived private threads the user has joined
func (*BrowserClient) GetLatestAttachmentData ¶
func (c *BrowserClient) GetLatestAttachmentData(ctx context.Context, channelID string) ([]byte, string, string, error)
GetLatestAttachmentData downloads the latest attachment's raw data, returning bytes, filename, and content type
func (*BrowserClient) GetLatestAttachmentURL ¶
func (c *BrowserClient) GetLatestAttachmentURL(ctx context.Context, channelID string) (string, error)
GetLatestAttachmentURL returns the CDN URL of the most recent attachment in a channel
func (*BrowserClient) GetMessage ¶
func (c *BrowserClient) GetMessage(ctx context.Context, channelID, messageID string) (*Message, error)
GetMessage fetches a single message by ID from a channel
func (*BrowserClient) GetMessageThread ¶
func (c *BrowserClient) GetMessageThread(ctx context.Context, channelID, messageID string) (*Thread, error)
GetMessageThread fetches the thread attached to a message (if any). Returns the thread if found, nil if no thread exists, or an error.
func (*BrowserClient) GetMessages ¶
func (c *BrowserClient) GetMessages(ctx context.Context, channelID string, opts *GetMessagesOptions) ([]*Message, error)
GetMessages gets messages from a channel
func (*BrowserClient) GetPrivateArchivedThreads ¶
func (c *BrowserClient) GetPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
GetPrivateArchivedThreads returns archived private threads in a channel
func (*BrowserClient) GetPublicArchivedThreads ¶
func (c *BrowserClient) GetPublicArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
GetPublicArchivedThreads returns archived public threads in a channel
func (*BrowserClient) GuildName ¶
func (c *BrowserClient) GuildName(guildID string) string
GuildName returns the guild ID as-is since browser mode does not cache guild names.
func (*BrowserClient) Initialize ¶
func (c *BrowserClient) Initialize(ctx context.Context) error
Initialize initializes the browser client
func (*BrowserClient) JoinGuild ¶
func (c *BrowserClient) JoinGuild(ctx context.Context, inviteCode string) error
JoinGuild joins a guild using an invite code
func (*BrowserClient) ListenForEvents ¶
func (c *BrowserClient) ListenForEvents(ctx context.Context, eventHandler EventHandler) error
ListenForEvents starts listening for WebSocket events
func (*BrowserClient) SearchMessages ¶
func (c *BrowserClient) SearchMessages(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (*MessageSearchResponse, error)
SearchMessages searches messages in a channel within a guild. If guildID is empty, it will be resolved from the channel.
func (*BrowserClient) SendMessage ¶
func (c *BrowserClient) SendMessage(ctx context.Context, channelID string, content string) (*Message, error)
SendMessage sends a message to a channel
func (*BrowserClient) SetGuildName ¶
func (c *BrowserClient) SetGuildName(guildID, name string)
SetGuildName is a no-op in browser mode.
func (*BrowserClient) SubscribeToAllGuildFeatures ¶
func (c *BrowserClient) SubscribeToAllGuildFeatures(guildID string) error
SubscribeToAllGuildFeatures subscribes to all available features for a guild
func (*BrowserClient) SubscribeToGuild ¶
func (c *BrowserClient) SubscribeToGuild(guildID string, options GuildSubscribeOptions) error
SubscribeToGuild subscribes to a single guild with specified features
func (*BrowserClient) SubscribeToGuildChannels ¶
func (c *BrowserClient) SubscribeToGuildChannels(guildID string, channels map[string][][]int) error
SubscribeToGuildChannels subscribes to specific channels with message ranges
func (*BrowserClient) SubscribeToGuildMembers ¶
func (c *BrowserClient) SubscribeToGuildMembers(guildID string, memberIDs []string) error
SubscribeToGuildMembers subscribes to specific members in a guild
func (*BrowserClient) SubscribeToGuildThreads ¶
func (c *BrowserClient) SubscribeToGuildThreads(guildID string, threadIDs []string) error
SubscribeToGuildThreads subscribes to threads in a guild
func (*BrowserClient) UnsubscribeFromGuild ¶
func (c *BrowserClient) UnsubscribeFromGuild(guildID string) error
UnsubscribeFromGuild unsubscribes from a guild by setting all features to false
func (*BrowserClient) UpdateStatus ¶
func (c *BrowserClient) UpdateStatus(ctx context.Context, status string, game *Game, afk bool, since int64) error
UpdateStatus updates the user's status
type BulkGuildSubscribePayload ¶
type BulkGuildSubscribePayload map[string]GuildSubscribePayload
BulkGuildSubscribePayload represents a bulk guild subscription payload
type CallEvent ¶
type CallEvent struct {
ChannelID string `json:"channel_id"`
MessageID string `json:"message_id,omitempty"`
Region string `json:"region,omitempty"`
Ringing []string `json:"ringing,omitempty"`
EmbeddedActivities []EmbeddedActivity `json:"embedded_activities,omitempty"`
}
CallEvent represents call-related events
type Channel ¶
type Channel struct {
ID string `json:"id"`
Type int `json:"type"`
GuildID string `json:"guild_id"`
Name string `json:"name"`
Topic string `json:"topic"`
Position int `json:"position"`
ParentID string `json:"parent_id"`
Recipients []User `json:"recipients,omitempty"`
}
Channel represents a Discord channel
type ChannelPinsAckEvent ¶
type ChannelPinsAckEvent struct {
ChannelID string `json:"channel_id"`
Timestamp string `json:"timestamp"`
Version int `json:"version"`
}
ChannelPinsAckEvent represents channel pins acknowledgment
type ClientInfo ¶
type ClientInfo struct {
Version int `json:"version"`
OS string `json:"os"`
Client string `json:"client"`
}
ClientInfo represents client information in sessions
type ClientStatePayload ¶
type ClientStatePayload struct {
GuildVersions map[string]int `json:"guild_versions"`
HighestLastMessageID string `json:"highest_last_message_id"`
ReadStateVersion int `json:"read_state_version"`
UserGuildSettingsVersion int `json:"user_guild_settings_version"`
UserSettingsVersion int `json:"user_settings_version"`
PrivateChannelsVersion string `json:"private_channels_version"`
APICodeVersion int `json:"api_code_version"`
}
Client State payload structure
type ClientStatus ¶
type ClientStatus struct {
Desktop string `json:"desktop,omitempty"`
Mobile string `json:"mobile,omitempty"`
Web string `json:"web,omitempty"`
}
ClientStatus represents the client status across platforms
type Config ¶
type Config struct {
Token string // Discord user token
Username string // Discord username/email for login
Password string // Discord password for login
Mode Mode // Client mode (Browser or TLS)
UserAgent string // Custom user agent
Timeout time.Duration // Request timeout
ProxyURL string // Proxy URL (optional)
Debug bool // Enable debug logging
RateLimited bool // Enable rate limiting
Locale string // Discord locale (default "en-US")
Timezone string // Discord timezone (default "Europe/Paris")
// Browser-specific configuration
RemoteURL string // Remote browser URL (WebSocket or direct)
ChromePath string // Path to Chrome/Chromium binary
UseHeadless *bool // Use headless mode (nil = auto-detect from env)
BrowserTimeout time.Duration // Browser operation timeout
DisableImages bool // Disable image loading for better performance
}
Config holds the configuration for the Discord client
func DefaultConfig ¶
DefaultConfig returns a default configuration
type ConnectionEvent ¶
type ConnectionEvent struct {
Type string `json:"type"`
ID string `json:"id"`
Name string `json:"name"`
Visibility int `json:"visibility"`
FriendSync bool `json:"friend_sync"`
ShowActivity bool `json:"show_activity"`
Verified bool `json:"verified"`
}
ConnectionEvent represents connection events
type ConversationSummary ¶
type ConversationSummary struct {
Count int `json:"count"`
EndID string `json:"end_id"`
ID string `json:"id"`
MessageIDs []string `json:"message_ids"`
People []string `json:"people"`
Source int `json:"source"`
StartID string `json:"start_id"`
SummShort string `json:"summ_short"`
Topic string `json:"topic"`
Type int `json:"type"`
Unsafe bool `json:"unsafe"`
}
ConversationSummary represents a conversation summary
type ConversationSummaryUpdateEvent ¶
type ConversationSummaryUpdateEvent struct {
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
Summaries []ConversationSummary `json:"summaries"`
}
ConversationSummaryUpdateEvent represents conversation summary updates
type DiscordClient ¶
type DiscordClient interface {
// Initialize the client
Initialize(ctx context.Context) error
// Close the client and cleanup resources
Close() error
// Get current user info
GetCurrentUser(ctx context.Context) (*User, error)
// Send a message to a channel
SendMessage(ctx context.Context, channelID string, content string) (*Message, error)
// Get messages from a channel
// Options: before (message ID), limit (default 50)
GetMessages(ctx context.Context, channelID string, opts *GetMessagesOptions) ([]*Message, error)
// Get all messages from a channel with automatic pagination
// Options: limit, before, after, oldestFirst, progressCB
GetAllMessages(ctx context.Context, channelID string, opts *GetAllMessagesOptions) ([]*Message, error)
// Join a guild/server
JoinGuild(ctx context.Context, inviteCode string) error
// Get guild info
GetGuild(ctx context.Context, guildID string) (*Guild, error)
// Get user's guilds
GetGuilds(ctx context.Context) ([]*Guild, error)
// Get guild member count
GetGuildMemberCount(ctx context.Context, guildID string) (int, error)
// Get guild emojis
GetGuildEmojis(ctx context.Context, guildID string) ([]*Emoji, error)
// Get guild members
GetGuildMembers(ctx context.Context, guildID string, limit int) ([]*GuildMember, error)
// React to a message
// emoji can be a string (unicode emoji like "👍" or custom emoji like "smile:123456789"),
// an *Emoji object, or an EmojiReaction object
AddReaction(ctx context.Context, channelID, messageID string, emoji interface{}) error
// Get channel info
GetChannel(ctx context.Context, channelID string) (*Channel, error)
// Get all channels in a guild
GetGuildChannels(ctx context.Context, guildID string) ([]*Channel, error)
// SearchMessages searches messages in a channel within a guild.
// If guildID is empty, it will be resolved from the channel.
SearchMessages(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (*MessageSearchResponse, error)
// GetChannelMessageCount returns the total number of messages in a channel.
// If guildID is empty, it will be resolved from the channel.
// If options is nil, defaults are used (no query filter).
GetChannelMessageCount(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (int, error)
// WebSocket methods
ConnectWebSocket(ctx context.Context) error
ListenForEvents(ctx context.Context, eventHandler EventHandler) error
UpdateStatus(ctx context.Context, status string, game *Game, afk bool, since int64) error
// Guild subscription methods
SubscribeToGuild(guildID string, options GuildSubscribeOptions) error
BulkSubscribeToGuilds(subscriptions map[string]GuildSubscribeOptions) error
SubscribeToGuildMembers(guildID string, memberIDs []string) error
SubscribeToGuildThreads(guildID string, threadIDs []string) error
SubscribeToGuildChannels(guildID string, channels map[string][][]int) error
SubscribeToAllGuildFeatures(guildID string) error
UnsubscribeFromGuild(guildID string) error
// Name resolution
GuildName(guildID string) string
SetGuildName(guildID, name string)
// CDN helpers
// GetLatestAttachmentURL searches recent messages in a channel and returns the first attachment CDN URL found.
GetLatestAttachmentURL(ctx context.Context, channelID string) (string, error)
// GetLatestAttachmentData downloads the latest attachment's raw bytes, returning data, filename, and content type.
GetLatestAttachmentData(ctx context.Context, channelID string) ([]byte, string, string, error)
// DownloadCDN downloads a resource directly from a Discord CDN URL.
DownloadCDN(ctx context.Context, assetURL string) ([]byte, string, error)
// Thread methods
// GetMessage fetches a single message by ID from a channel
GetMessage(ctx context.Context, channelID, messageID string) (*Message, error)
// GetMessageThread fetches the thread attached to a message (if any)
GetMessageThread(ctx context.Context, channelID, messageID string) (*Thread, error)
// GetActiveThreads returns all active threads in a guild
GetActiveThreads(ctx context.Context, guildID string) (*ThreadListResponse, error)
// GetPublicArchivedThreads returns archived public threads in a channel
GetPublicArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
// GetPrivateArchivedThreads returns archived private threads in a channel
GetPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
// GetJoinedPrivateArchivedThreads returns archived private threads the user has joined
GetJoinedPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
}
DiscordClient represents a Discord selfbot client
func NewClient ¶
func NewClient(config Config) DiscordClient
NewClient creates a new Discord client based on the specified mode
type DiscordWebSocket ¶
type DiscordWebSocket struct {
// contains filtered or unexported fields
}
Enhanced WebSocket Client
func NewDiscordWebSocket ¶
func NewDiscordWebSocket(config Config) *DiscordWebSocket
NewDiscordWebSocket creates a new enhanced WebSocket client
func (*DiscordWebSocket) AddChannelCreateHandler ¶
func (ws *DiscordWebSocket) AddChannelCreateHandler(handler func(*Channel) error)
AddChannelCreateHandler adds a handler for CHANNEL_CREATE events
func (*DiscordWebSocket) AddChannelDeleteHandler ¶
func (ws *DiscordWebSocket) AddChannelDeleteHandler(handler func(*Channel) error)
AddChannelDeleteHandler adds a handler for CHANNEL_DELETE events
func (*DiscordWebSocket) AddChannelUpdateHandler ¶
func (ws *DiscordWebSocket) AddChannelUpdateHandler(handler func(*Channel) error)
AddChannelUpdateHandler adds a handler for CHANNEL_UPDATE events
func (*DiscordWebSocket) AddConversationSummaryUpdateHandler ¶
func (ws *DiscordWebSocket) AddConversationSummaryUpdateHandler(handler func(*ConversationSummaryUpdateEvent) error)
AddConversationSummaryUpdateHandler adds a handler for CONVERSATION_SUMMARY_UPDATE events
func (*DiscordWebSocket) AddEventHandler ¶
func (ws *DiscordWebSocket) AddEventHandler(eventType string, handler EventHandler)
AddEventHandler adds an event handler for a specific event type
func (*DiscordWebSocket) AddGuildCreateHandler ¶
func (ws *DiscordWebSocket) AddGuildCreateHandler(handler func(*Guild) error)
AddGuildCreateHandler adds a handler for GUILD_CREATE events
func (*DiscordWebSocket) AddGuildDeleteHandler ¶
func (ws *DiscordWebSocket) AddGuildDeleteHandler(handler func(*GuildDeleteEvent) error)
AddGuildDeleteHandler adds a handler for GUILD_DELETE events
func (*DiscordWebSocket) AddGuildMemberAddHandler ¶
func (ws *DiscordWebSocket) AddGuildMemberAddHandler(handler func(*GuildMemberEvent) error)
AddGuildMemberAddHandler adds a handler for GUILD_MEMBER_ADD events
func (*DiscordWebSocket) AddGuildScheduledEventUserAddHandler ¶
func (ws *DiscordWebSocket) AddGuildScheduledEventUserAddHandler(handler func(*GuildScheduledEventUserEvent) error)
AddGuildScheduledEventUserAddHandler adds a handler for GUILD_SCHEDULED_EVENT_USER_ADD events
func (*DiscordWebSocket) AddGuildScheduledEventUserRemoveHandler ¶
func (ws *DiscordWebSocket) AddGuildScheduledEventUserRemoveHandler(handler func(*GuildScheduledEventUserEvent) error)
AddGuildScheduledEventUserRemoveHandler adds a handler for GUILD_SCHEDULED_EVENT_USER_REMOVE events
func (*DiscordWebSocket) AddGuildUpdateHandler ¶
func (ws *DiscordWebSocket) AddGuildUpdateHandler(handler func(*Guild) error)
AddGuildUpdateHandler adds a handler for GUILD_UPDATE events
func (*DiscordWebSocket) AddMessageCreateHandler ¶
func (ws *DiscordWebSocket) AddMessageCreateHandler(handler func(*Message) error)
AddMessageCreateHandler adds a handler for MESSAGE_CREATE events
func (*DiscordWebSocket) AddMessageDeleteHandler ¶
func (ws *DiscordWebSocket) AddMessageDeleteHandler(handler func(*MessageDeleteEvent) error)
AddMessageDeleteHandler adds a handler for MESSAGE_DELETE events
func (*DiscordWebSocket) AddMessageReactionAddHandler ¶
func (ws *DiscordWebSocket) AddMessageReactionAddHandler(handler func(*MessageReactionEvent) error)
AddMessageReactionAddHandler adds a handler for MESSAGE_REACTION_ADD events
func (*DiscordWebSocket) AddMessageReactionAddManyHandler ¶
func (ws *DiscordWebSocket) AddMessageReactionAddManyHandler(handler func(*MessageReactionAddManyEvent) error)
AddMessageReactionAddManyHandler adds a handler for MESSAGE_REACTION_ADD_MANY events
func (*DiscordWebSocket) AddMessageReactionRemoveHandler ¶
func (ws *DiscordWebSocket) AddMessageReactionRemoveHandler(handler func(*MessageReactionEvent) error)
AddMessageReactionRemoveHandler adds a handler for MESSAGE_REACTION_REMOVE events
func (*DiscordWebSocket) AddMessageUpdateHandler ¶
func (ws *DiscordWebSocket) AddMessageUpdateHandler(handler func(*Message) error)
AddMessageUpdateHandler adds a handler for MESSAGE_UPDATE events
func (*DiscordWebSocket) AddTestEventHandler ¶
func (ws *DiscordWebSocket) AddTestEventHandler(handler func(*TestEvent) error)
AddTestEventHandler adds a handler for TEST_EVENT events
func (*DiscordWebSocket) AddThreadCreateHandler ¶
func (ws *DiscordWebSocket) AddThreadCreateHandler(handler func(*ThreadEvent) error)
AddThreadCreateHandler adds a handler for THREAD_CREATE events
func (*DiscordWebSocket) AddThreadDeleteHandler ¶
func (ws *DiscordWebSocket) AddThreadDeleteHandler(handler func(*ThreadDeleteEvent) error)
AddThreadDeleteHandler adds a handler for THREAD_DELETE events
func (*DiscordWebSocket) AddThreadListSyncHandler ¶
func (ws *DiscordWebSocket) AddThreadListSyncHandler(handler func(*ThreadListSyncEvent) error)
AddThreadListSyncHandler adds a handler for THREAD_LIST_SYNC events
func (*DiscordWebSocket) AddThreadMemberListUpdateHandler ¶
func (ws *DiscordWebSocket) AddThreadMemberListUpdateHandler(handler func(*ThreadMemberListUpdateEvent) error)
AddThreadMemberListUpdateHandler adds a handler for THREAD_MEMBER_LIST_UPDATE events This is sent after subscribing to a thread member list via SubscribeToGuildThreads
func (*DiscordWebSocket) AddThreadMemberUpdateHandler ¶
func (ws *DiscordWebSocket) AddThreadMemberUpdateHandler(handler func(*ThreadMemberUpdateEvent) error)
AddThreadMemberUpdateHandler adds a handler for THREAD_MEMBER_UPDATE events This is sent when the current user's thread member object is updated
func (*DiscordWebSocket) AddThreadMembersUpdateHandler ¶
func (ws *DiscordWebSocket) AddThreadMembersUpdateHandler(handler func(*ThreadMembersUpdateEvent) error)
AddThreadMembersUpdateHandler adds a handler for THREAD_MEMBERS_UPDATE events This is sent when members are added or removed from a thread
func (*DiscordWebSocket) AddThreadUpdateHandler ¶
func (ws *DiscordWebSocket) AddThreadUpdateHandler(handler func(*ThreadEvent) error)
AddThreadUpdateHandler adds a handler for THREAD_UPDATE events
func (*DiscordWebSocket) AddTypingStartHandler ¶
func (ws *DiscordWebSocket) AddTypingStartHandler(handler func(*TypingStartEvent) error)
AddTypingStartHandler adds a handler for TYPING_START events
func (*DiscordWebSocket) AddUserUpdateHandler ¶
func (ws *DiscordWebSocket) AddUserUpdateHandler(handler func(*User) error)
AddUserUpdateHandler adds a handler for USER_UPDATE events
func (*DiscordWebSocket) AddVoiceStateUpdateHandler ¶
func (ws *DiscordWebSocket) AddVoiceStateUpdateHandler(handler func(*VoiceState) error)
AddVoiceStateUpdateHandler adds a handler for VOICE_STATE_UPDATE events
func (*DiscordWebSocket) BulkSubscribeToGuilds ¶
func (ws *DiscordWebSocket) BulkSubscribeToGuilds(subscriptions map[string]GuildSubscribeOptions) error
BulkSubscribeToGuilds subscribes to multiple guilds at once
func (*DiscordWebSocket) Close ¶
func (ws *DiscordWebSocket) Close() error
Close closes the WebSocket connection
func (*DiscordWebSocket) Connect ¶
func (ws *DiscordWebSocket) Connect(ctx context.Context) error
Connect establishes connection to Discord Gateway
func (*DiscordWebSocket) EnableAllEventLogging ¶
func (ws *DiscordWebSocket) EnableAllEventLogging()
EnableAllEventLogging enables logging for all supported events
func (*DiscordWebSocket) GuildName ¶
func (ws *DiscordWebSocket) GuildName(guildID string) string
GuildName returns the cached guild name for the given ID, or the ID itself if not found.
func (*DiscordWebSocket) IsConnected ¶
func (ws *DiscordWebSocket) IsConnected() bool
IsConnected returns whether the WebSocket is connected
func (*DiscordWebSocket) SendMessage ¶
func (ws *DiscordWebSocket) SendMessage(op int, data interface{}) error
SendMessage sends a message through the WebSocket
func (*DiscordWebSocket) SetGuildName ¶
func (ws *DiscordWebSocket) SetGuildName(guildID, name string)
SetGuildName stores a guild name in the cache for later resolution.
func (*DiscordWebSocket) SubscribeToAllGuildFeatures ¶
func (ws *DiscordWebSocket) SubscribeToAllGuildFeatures(guildID string) error
SubscribeToAllGuildFeatures subscribes to all available features for a guild
func (*DiscordWebSocket) SubscribeToGuild ¶
func (ws *DiscordWebSocket) SubscribeToGuild(guildID string, options GuildSubscribeOptions) error
SubscribeToGuild subscribes to a single guild with specified features
func (*DiscordWebSocket) SubscribeToGuildChannels ¶
func (ws *DiscordWebSocket) SubscribeToGuildChannels(guildID string, channels map[string][][]int) error
SubscribeToGuildChannels subscribes to specific channels with message ranges
func (*DiscordWebSocket) SubscribeToGuildMembers ¶
func (ws *DiscordWebSocket) SubscribeToGuildMembers(guildID string, memberIDs []string) error
SubscribeToGuildMembers subscribes to specific members in a guild
func (*DiscordWebSocket) SubscribeToGuildThreads ¶
func (ws *DiscordWebSocket) SubscribeToGuildThreads(guildID string, threadIDs []string) error
SubscribeToGuildThreads subscribes to threads in a guild
func (*DiscordWebSocket) UnsubscribeFromGuild ¶
func (ws *DiscordWebSocket) UnsubscribeFromGuild(guildID string) error
UnsubscribeFromGuild unsubscribes from a guild by setting all features to false
type EmbeddedActivity ¶
type EmbeddedActivity struct {
ApplicationID string `json:"application_id"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id,omitempty"`
MaxAge int `json:"max_age"`
MaxUses int `json:"max_uses"`
Code string `json:"code"`
Temporary bool `json:"temporary"`
Uses int `json:"uses"`
CreatedAt string `json:"created_at"`
}
EmbeddedActivity represents an embedded activity in a call
type Emoji ¶
type Emoji struct {
ID string `json:"id"`
Name string `json:"name"`
Roles []string `json:"roles"`
User *User `json:"user"`
RequireColons bool `json:"require_colons"`
Managed bool `json:"managed"`
Animated bool `json:"animated"`
Available bool `json:"available"`
}
Emoji represents a Discord custom emoji
type EmojiReaction ¶
EmojiReaction represents an emoji in reactions
type EventHandler ¶
type EventHandler func(event *WebSocketEvent) error
EventHandler is a function that handles WebSocket events
type FriendSuggestionEvent ¶
type FriendSuggestionEvent struct {
SuggestedUserID string `json:"suggested_user_id"`
Reasons []struct {
Type int `json:"type"`
Name string `json:"name"`
} `json:"reasons,omitempty"`
}
FriendSuggestionEvent represents friend suggestion events
type GatewayEvent ¶
type GatewayEvent struct {
Op int `json:"op"`
Data json.RawMessage `json:"d"`
Type string `json:"t"`
}
GatewayEvent represents a Discord Gateway event
type GatewayMessageEvent ¶
type GatewayMessageEvent struct {
Message Message `json:"message"`
}
GatewayMessageEvent represents a message event
type GatewayPayload ¶
type GatewayPayload struct {
Op int `json:"op"`
Data json.RawMessage `json:"d"`
Type string `json:"t,omitempty"`
Sequence *int64 `json:"s,omitempty"`
}
Gateway Payload represents a Discord Gateway message
type GatewayReadyEvent ¶
type GatewayReadyEvent struct {
User User `json:"user"`
Guilds []Guild `json:"guilds"`
Session string `json:"session_id"`
}
GatewayReadyEvent represents the ready event data
type GetAllMessagesOptions ¶
type GetAllMessagesOptions struct {
Limit int // Maximum number of messages to fetch (0 = unlimited)
Before string // Start fetching before this message ID (optional)
After string // Start fetching after this message ID (optional)
OldestFirst *bool // If true, return messages oldest->newest; defaults to true when After is set
ProgressCB func(p ProgressInfo) // Optional progress callback
}
GetAllMessagesOptions contains options for fetching all messages from a channel. Mirrors discord.py-self history() parameters for pagination and ordering.
type GetMessagesOptions ¶
type GetMessagesOptions struct {
Before string // Get messages before this message ID (optional)
After string // Get messages after this message ID (optional)
Around string // Get messages around this message ID (optional, max limit 101)
Limit int // Number of messages to fetch (default 50, max 100 unless Around is set)
}
GetMessagesOptions contains options for fetching messages from a channel
type Guild ¶
type Guild struct {
ID string `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"`
Description string `json:"description"`
OwnerID string `json:"owner_id"`
Region string `json:"region"`
MemberCount int `json:"member_count"`
Channels []Channel `json:"channels,omitempty"`
}
Guild represents a Discord guild/server
type GuildDeleteEvent ¶
type GuildDeleteEvent struct {
ID string `json:"id"`
}
GuildDeleteEvent represents a guild deletion (or leaving)
type GuildMember ¶
type GuildMember struct {
User *User `json:"user"`
Nick *string `json:"nick"`
Avatar *string `json:"avatar"`
Roles []string `json:"roles"`
JoinedAt *time.Time `json:"joined_at"`
PremiumSince *time.Time `json:"premium_since"`
Deaf bool `json:"deaf"`
Mute bool `json:"mute"`
Flags int `json:"flags"`
Pending bool `json:"pending"`
CommunicationDisabledUntil *time.Time `json:"communication_disabled_until"`
}
GuildMember represents a Discord guild member with user info
type GuildMemberEvent ¶
type GuildMemberEvent struct {
GuildID string `json:"guild_id"`
User User `json:"user"`
Nick *string `json:"nick"`
Avatar *string `json:"avatar"`
Roles []string `json:"roles"`
JoinedAt string `json:"joined_at"`
PremiumSince *string `json:"premium_since"`
Deaf bool `json:"deaf"`
Mute bool `json:"mute"`
Flags int `json:"flags"`
Pending bool `json:"pending"`
Permissions string `json:"permissions,omitempty"`
CommunicationDisabledUntil *string `json:"communication_disabled_until"`
}
GuildMemberEvent represents guild member related events
type GuildMemberListGroup ¶
GuildMemberListGroup represents a member list group
type GuildMemberListOP ¶
type GuildMemberListOP struct {
Op string `json:"op"`
Range []int `json:"range,omitempty"`
Index int `json:"index,omitempty"`
Items []interface{} `json:"items,omitempty"`
Item interface{} `json:"item,omitempty"`
}
GuildMemberListOP represents member list operations
type GuildMemberListUpdateEvent ¶
type GuildMemberListUpdateEvent struct {
ID string `json:"id"`
GuildID string `json:"guild_id"`
MemberCount int `json:"member_count"`
OnlineCount int `json:"online_count"`
Groups []GuildMemberListGroup `json:"groups"`
Ops []GuildMemberListOP `json:"ops"`
}
GuildMemberListUpdateEvent represents guild member list updates
type GuildScheduledEvent ¶
type GuildScheduledEvent struct {
ID string `json:"id"`
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id,omitempty"`
CreatorID string `json:"creator_id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
ScheduledStartTime string `json:"scheduled_start_time"`
ScheduledEndTime string `json:"scheduled_end_time,omitempty"`
PrivacyLevel int `json:"privacy_level"`
Status int `json:"status"`
EntityType int `json:"entity_type"`
EntityID string `json:"entity_id,omitempty"`
EntityMetadata interface{} `json:"entity_metadata,omitempty"`
Creator *User `json:"creator,omitempty"`
UserCount int `json:"user_count,omitempty"`
Image string `json:"image,omitempty"`
}
GuildScheduledEvent represents guild scheduled events
type GuildScheduledEventUserEvent ¶
type GuildScheduledEventUserEvent struct {
GuildScheduledEventID string `json:"guild_scheduled_event_id"`
UserID string `json:"user_id"`
GuildID string `json:"guild_id"`
}
GuildScheduledEventUserEvent represents guild scheduled event user actions
type GuildSubscribeOptions ¶
type GuildSubscribeOptions struct {
Typing *bool `json:"typing,omitempty"`
Threads *bool `json:"threads,omitempty"`
Activities *bool `json:"activities,omitempty"`
MemberUpdates *bool `json:"member_updates,omitempty"`
Members []string `json:"members,omitempty"`
Channels map[string][][]int `json:"channels,omitempty"`
ThreadMemberLists []string `json:"thread_member_lists,omitempty"`
}
GuildSubscribeOptions represents options for guild subscription
type GuildSubscribePayload ¶
type GuildSubscribePayload struct {
GuildID string `json:"guild_id"`
Typing *bool `json:"typing,omitempty"`
Threads *bool `json:"threads,omitempty"`
Activities *bool `json:"activities,omitempty"`
MemberUpdates *bool `json:"member_updates,omitempty"`
Members []string `json:"members,omitempty"`
Channels map[string][][]int `json:"channels,omitempty"`
ThreadMemberLists []string `json:"thread_member_lists,omitempty"`
}
GuildSubscribePayload represents a single guild subscription payload
type HelloPayload ¶
type HelloPayload struct {
HeartbeatInterval int `json:"heartbeat_interval"`
}
Hello payload structure
type IdentifyPayload ¶
type IdentifyPayload struct {
Token string `json:"token"`
Capabilities int `json:"capabilities"`
Properties map[string]interface{} `json:"properties"`
Presence *PresencePayload `json:"presence,omitempty"`
Compress bool `json:"compress"`
ClientState *ClientStatePayload `json:"client_state"`
}
Identify payload structure
type InviteEvent ¶
type InviteEvent struct {
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id,omitempty"`
Code string `json:"code"`
CreatedAt string `json:"created_at,omitempty"`
GuildScheduledEventID string `json:"guild_scheduled_event_id,omitempty"`
Inviter *User `json:"inviter,omitempty"`
MaxAge int `json:"max_age,omitempty"`
MaxUses int `json:"max_uses,omitempty"`
TargetType int `json:"target_type,omitempty"`
TargetUser *User `json:"target_user,omitempty"`
TargetApplication interface{} `json:"target_application,omitempty"`
Temporary bool `json:"temporary,omitempty"`
Uses int `json:"uses,omitempty"`
}
InviteEvent represents invite-related events
type Member ¶
type Member struct {
Roles []string `json:"roles"`
PremiumSince *time.Time `json:"premium_since"`
Pending bool `json:"pending"`
Nick *string `json:"nick"`
Mute bool `json:"mute"`
JoinedAt time.Time `json:"joined_at"`
Flags int `json:"flags"`
Deaf bool `json:"deaf"`
CommunicationDisabledUntil *time.Time `json:"communication_disabled_until"`
Banner *string `json:"banner"`
Avatar *string `json:"avatar"`
}
Member represents a Discord guild member
type MergedMembers ¶
type MergedMembers [][]GuildMemberEvent
MergedMembers represents merged member data
type MergedPresences ¶
type MergedPresences struct {
Guilds [][]PresenceUpdateEvent `json:"guilds"`
Friends []PresenceUpdateEvent `json:"friends"`
}
MergedPresences represents merged presence data
type Message ¶
type Message struct {
ID string `json:"id"`
Type int `json:"type"`
Content string `json:"content"`
ChannelID string `json:"channel_id"`
ChannelType int `json:"channel_type"`
GuildID string `json:"guild_id"`
Author *User `json:"author"`
Member *Member `json:"member"`
Timestamp time.Time `json:"timestamp"`
EditedTimestamp *time.Time `json:"edited_timestamp"`
Flags int `json:"flags"`
Mentions []*User `json:"mentions"`
MentionRoles []string `json:"mention_roles"`
MentionEveryone bool `json:"mention_everyone"`
Attachments []map[string]interface{} `json:"attachments"`
Embeds []map[string]interface{} `json:"embeds"`
Components []map[string]interface{} `json:"components"`
Reactions []map[string]interface{} `json:"reactions"`
Pinned bool `json:"pinned"`
TTS bool `json:"tts"`
Nonce string `json:"nonce"`
Thread *Thread `json:"thread,omitempty"` // Thread started from this message
StickerItems []*StickerItem `json:"sticker_items,omitempty"`
}
Message represents a Discord message
func ParseMessageFromMap ¶
ParseMessageFromMap converts a raw map to a Message struct
type MessageAckEvent ¶
type MessageAckEvent struct {
ChannelID string `json:"channel_id"`
MessageID string `json:"message_id"`
Flags *int `json:"flags"`
LastViewed *int `json:"last_viewed"`
Manual bool `json:"manual,omitempty"`
MentionCount int `json:"mention_count,omitempty"`
AckType int `json:"ack_type,omitempty"`
Version int `json:"version"`
}
MessageAckEvent represents message acknowledgment
type MessageCache ¶
type MessageCache struct {
// contains filtered or unexported fields
}
MessageCache represents a cache for Discord messages
func NewMessageCache ¶
func NewMessageCache() *MessageCache
NewMessageCache creates a new message cache
func (*MessageCache) Add ¶
func (c *MessageCache) Add(message map[string]interface{})
Add adds a message to the cache
func (*MessageCache) Delete ¶
func (c *MessageCache) Delete(id string)
Delete removes a message from the cache
func (*MessageCache) Get ¶
func (c *MessageCache) Get(id string) (map[string]interface{}, bool)
Get retrieves a message from the cache
func (*MessageCache) Update ¶
func (c *MessageCache) Update(message map[string]interface{})
Update updates a message in the cache
type MessageDeleteEvent ¶
type MessageDeleteEvent struct {
ID string `json:"id"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id,omitempty"`
}
MessageDeleteEvent represents a message deletion
type MessageReactionAddManyEvent ¶
type MessageReactionAddManyEvent struct {
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
MessageID string `json:"message_id"`
Reactions []MessageReactionManyItem `json:"reactions"`
}
MessageReactionAddManyEvent represents bulk reaction additions
type MessageReactionEvent ¶
type MessageReactionEvent struct {
UserID string `json:"user_id"`
ChannelID string `json:"channel_id"`
MessageID string `json:"message_id"`
GuildID string `json:"guild_id,omitempty"`
Member *Member `json:"member,omitempty"`
Emoji EmojiReaction `json:"emoji"`
}
MessageReactionEvent represents a reaction add/remove event
type MessageReactionManyItem ¶
type MessageReactionManyItem struct {
Emoji EmojiReaction `json:"emoji"`
Users []string `json:"users"`
}
MessageReactionManyItem represents a reaction item in bulk reactions
type MessageSearchOptions ¶
type MessageSearchOptions struct {
Query string // Search query text (content filter)
AuthorID string // Filter by author ID
Offset int // Pagination offset (default 0)
SortBy string // Sort field (default "timestamp")
SortOrder string // Sort direction: "asc" or "desc" (default "desc")
}
MessageSearchOptions contains options for searching messages in a channel
type MessageSearchResponse ¶
type MessageSearchResponse struct {
TotalResults int `json:"total_results"`
Messages [][]map[string]interface{} `json:"messages"`
AnalyticsID string `json:"analytics_id"`
}
MessageSearchResponse represents the response from a message search
type PartialUpdateChannel ¶
type PartialUpdateChannel struct {
ID string `json:"id"`
LastMessageID *string `json:"last_message_id"`
LastPinTimestamp *string `json:"last_pin_timestamp,omitempty"`
}
PartialUpdateChannel represents partial channel update data
type PassiveUpdateV1Event ¶
type PassiveUpdateV1Event struct {
GuildID string `json:"guild_id"`
Channels []PartialUpdateChannel `json:"channels"`
VoiceStates []VoiceState `json:"voice_states,omitempty"`
Members []GuildMemberEvent `json:"members,omitempty"`
}
PassiveUpdateV1Event represents passive guild updates (version 1)
type PassiveUpdateV2Event ¶
type PassiveUpdateV2Event struct {
GuildID string `json:"guild_id"`
RemovedVoiceStates []string `json:"removed_voice_states"`
UpdatedChannels []PartialUpdateChannel `json:"updated_channels"`
Members []GuildMemberEvent `json:"members"`
UpdatedVoiceStates []VoiceState `json:"updated_voice_states"`
}
PassiveUpdateV2Event represents passive guild updates (version 2)
type PaymentUpdateEvent ¶
type PaymentUpdateEvent struct {
ID string `json:"id"`
Status int `json:"status"`
Amount int `json:"amount"`
Currency string `json:"currency"`
PaymentGateway int `json:"payment_gateway"`
}
PaymentUpdateEvent represents payment updates
type PresencePayload ¶
type PresencePayload struct {
Status string `json:"status"`
Since int64 `json:"since"`
Activities []Activity `json:"activities"`
AFK bool `json:"afk"`
}
Presence payload structure
type PresenceUpdateEvent ¶
type PresenceUpdateEvent struct {
User User `json:"user"`
GuildID string `json:"guild_id,omitempty"`
Status string `json:"status"`
Activities []Activity `json:"activities"`
ClientStatus ClientStatus `json:"client_status"`
ProcessedAtTimestamp int64 `json:"processed_at_timestamp,omitempty"`
}
Enhanced PresenceUpdateEvent represents presence updates (matching events/PRESENCE_UPDATE.json)
type ProgressInfo ¶
type ProgressInfo struct {
CurrentCount int `json:"current_count"` // Messages fetched in the current batch
TotalFetched int `json:"total_fetched"` // Total messages fetched so far
EstimatedTotal int `json:"estimated_total"` // Estimated total messages in the channel
}
ProgressInfo contains progress information for GetAllMessages
type RateLimitResponse ¶
type RateLimitResponse struct {
Message string `json:"message"`
RetryAfter float64 `json:"retry_after"`
Global bool `json:"global"`
}
RateLimitResponse represents a Discord rate limit error response
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter handles Discord API rate limiting
type ReadyPayload ¶
type ReadyPayload struct {
Version int `json:"v"`
User User `json:"user"`
Guilds []Guild `json:"guilds"`
SessionID string `json:"session_id"`
ResumeGatewayURL string `json:"resume_gateway_url"`
Shard []int `json:"shard,omitempty"`
Application map[string]interface{} `json:"application"`
}
Ready Event payload
type ReadySupplementalEvent ¶
type ReadySupplementalEvent struct {
Guilds []SupplementalGuild `json:"guilds"`
MergedMembers MergedMembers `json:"merged_members"`
MergedPresences MergedPresences `json:"merged_presences"`
LazyPrivateChannels []Channel `json:"lazy_private_channels"`
UserActivities []Activity `json:"user_activities"`
GameInvites []interface{} `json:"game_invites"`
Disclose []string `json:"disclose"`
}
ReadySupplementalEvent represents the READY_SUPPLEMENTAL event
type ResumePayload ¶
type ResumePayload struct {
Token string `json:"token"`
SessionID string `json:"session_id"`
Sequence int64 `json:"seq"`
}
Resume payload structure
type Session ¶
type Session struct {
SessionID string `json:"session_id"`
Status string `json:"status"`
Activities []Activity `json:"activities"`
ClientInfo ClientInfo `json:"client_info"`
Active bool `json:"active,omitempty"`
HiddenActivities []Activity `json:"hidden_activities,omitempty"`
ProcessedAt int64 `json:"processed_at_timestamp,omitempty"`
}
Session represents a user session
type SessionsReplaceEvent ¶
type SessionsReplaceEvent []Session
SessionsReplaceEvent represents the SESSIONS_REPLACE event
type StickerItem ¶
type StickerItem struct {
ID string `json:"id"`
Name string `json:"name"`
FormatType int `json:"format_type"` // 1=PNG, 2=APNG, 3=LOTTIE, 4=GIF
}
StickerItem represents a sticker in a message
type SuperProperties ¶
type SuperProperties struct {
OS string `json:"os"`
Browser string `json:"browser"`
Device string `json:"device"`
SystemLocale string `json:"system_locale"`
BrowserVersion string `json:"browser_version"`
OSVersion string `json:"os_version"`
Referrer string `json:"referrer"`
ReferringDomain string `json:"referring_domain"`
ReferrerCurrent string `json:"referrer_current"`
ReferringDomainCurrent string `json:"referring_domain_current"`
ReleaseChannel string `json:"release_channel"`
ClientBuildNumber int `json:"client_build_number"`
ClientEventSource *string `json:"client_event_source"`
}
SuperProperties contains Discord client fingerprint properties used for X-Super-Properties header and WebSocket IDENTIFY
func BuildSuperProperties ¶
func BuildSuperProperties(locale string) *SuperProperties
BuildSuperProperties creates a SuperProperties struct with the given locale
func (*SuperProperties) ToBase64 ¶
func (sp *SuperProperties) ToBase64() string
ToBase64 encodes the SuperProperties as base64 JSON for X-Super-Properties header
func (*SuperProperties) ToMap ¶
func (sp *SuperProperties) ToMap() map[string]interface{}
ToMap converts SuperProperties to map[string]interface{} for WebSocket IDENTIFY
type SupplementalGuild ¶
type SupplementalGuild struct {
ID string `json:"id"`
VoiceStates []VoiceState `json:"voice_states"`
EmbeddedActivities []Activity `json:"embedded_activities"`
ActivityInstances []Activity `json:"activity_instances"`
}
SupplementalGuild represents supplemental guild data
type TLSClient ¶
type TLSClient struct {
// contains filtered or unexported fields
}
TLSClient implements DiscordClient using TLS client with enhanced WebSocket
func NewTLSClient ¶
NewTLSClient creates a new TLS-based Discord client
func (*TLSClient) AddReaction ¶
func (c *TLSClient) AddReaction(ctx context.Context, channelID, messageID string, emoji interface{}) error
AddReaction adds a reaction to a message. The emoji parameter can be:
- A string: Unicode emoji (e.g., "👍") or custom emoji in "name:id" format (e.g., "smile:123456789")
- An *Emoji object: Custom emoji from GetGuildEmojis()
- An EmojiReaction object: Emoji from reaction events
Examples:
- client.AddReaction(ctx, channelID, messageID, "👍")
- client.AddReaction(ctx, channelID, messageID, "smile:123456789")
- emojis, _ := client.GetGuildEmojis(ctx, guildID) client.AddReaction(ctx, channelID, messageID, emojis[0])
func (*TLSClient) BulkSubscribeToGuilds ¶
func (c *TLSClient) BulkSubscribeToGuilds(subscriptions map[string]GuildSubscribeOptions) error
BulkSubscribeToGuilds subscribes to multiple guilds at once
func (*TLSClient) ConnectWebSocket ¶
ConnectWebSocket establishes a WebSocket connection to Discord's Gateway using the enhanced client
func (*TLSClient) DownloadCDN ¶
DownloadCDN downloads a resource from a Discord CDN URL and returns bytes and content type
func (*TLSClient) GetActiveThreads ¶
func (c *TLSClient) GetActiveThreads(ctx context.Context, guildID string) (*ThreadListResponse, error)
GetActiveThreads returns all active threads in a guild
func (*TLSClient) GetAllMessages ¶
func (c *TLSClient) GetAllMessages(ctx context.Context, channelID string, opts *GetAllMessagesOptions) ([]*Message, error)
GetAllMessages fetches all messages from a channel with pagination. It mirrors discord.py-self's history() behavior:
- When After is set and OldestFirst is nil, messages are returned oldest->newest
- When Before is set (or neither), messages are returned newest->oldest
- OldestFirst can be explicitly set to override the default ordering
func (*TLSClient) GetChannel ¶
GetChannel gets channel information
func (*TLSClient) GetChannelMessageCount ¶
func (c *TLSClient) GetChannelMessageCount(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (int, error)
GetChannelMessageCount returns the total number of messages in a channel. If guildID is empty, it will be resolved from the channel. If options is nil, defaults are used (no query filter).
func (*TLSClient) GetCurrentUser ¶
GetCurrentUser gets the current user info
func (*TLSClient) GetGuildChannels ¶
GetGuildChannels gets all channels in a guild
func (*TLSClient) GetGuildEmojis ¶
GetGuildEmojis gets all emojis in a guild
func (*TLSClient) GetGuildMemberCount ¶
GetGuildMemberCount gets the number of members in a guild
func (*TLSClient) GetGuildMembers ¶
func (c *TLSClient) GetGuildMembers(ctx context.Context, guildID string, limit int) ([]*GuildMember, error)
GetGuildMembers gets members in a guild
func (*TLSClient) GetJoinedPrivateArchivedThreads ¶
func (c *TLSClient) GetJoinedPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
GetJoinedPrivateArchivedThreads returns archived private threads the user has joined
func (*TLSClient) GetLatestAttachmentData ¶
func (c *TLSClient) GetLatestAttachmentData(ctx context.Context, channelID string) ([]byte, string, string, error)
GetLatestAttachmentData downloads the latest attachment's raw data, returning bytes, filename, and content type
func (*TLSClient) GetLatestAttachmentURL ¶
GetLatestAttachmentURL returns the CDN URL of the most recent attachment in a channel
func (*TLSClient) GetMessage ¶
GetMessage fetches a single message by ID from a channel
func (*TLSClient) GetMessageThread ¶
func (c *TLSClient) GetMessageThread(ctx context.Context, channelID, messageID string) (*Thread, error)
GetMessageThread fetches the thread attached to a message (if any). Returns the thread if found, nil if no thread exists, or an error.
func (*TLSClient) GetMessages ¶
func (c *TLSClient) GetMessages(ctx context.Context, channelID string, opts *GetMessagesOptions) ([]*Message, error)
GetMessages gets messages from a channel
func (*TLSClient) GetPrivateArchivedThreads ¶
func (c *TLSClient) GetPrivateArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
GetPrivateArchivedThreads returns archived private threads in a channel
func (*TLSClient) GetPublicArchivedThreads ¶
func (c *TLSClient) GetPublicArchivedThreads(ctx context.Context, channelID string, opts *ArchivedThreadsOptions) (*ThreadListResponse, error)
GetPublicArchivedThreads returns archived public threads in a channel
func (*TLSClient) GuildName ¶
GuildName returns the cached guild name for the given ID, or the ID itself if not found.
func (*TLSClient) Initialize ¶
Initialize initializes the TLS client
func (*TLSClient) IsConnected ¶
IsConnected checks if the WebSocket connection is active
func (*TLSClient) ListenForEvents ¶
func (c *TLSClient) ListenForEvents(ctx context.Context, eventHandler EventHandler) error
ListenForEvents starts listening for WebSocket events using the enhanced client
func (*TLSClient) SearchMessages ¶
func (c *TLSClient) SearchMessages(ctx context.Context, guildID, channelID string, options *MessageSearchOptions) (*MessageSearchResponse, error)
SearchMessages searches messages in a channel within a guild. If guildID is empty, it will be resolved from the channel.
func (*TLSClient) SendMessage ¶
func (c *TLSClient) SendMessage(ctx context.Context, channelID string, content string) (*Message, error)
SendMessage sends a message to a channel
func (*TLSClient) SetGuildName ¶
SetGuildName stores a guild name in the WebSocket cache for debug log resolution.
func (*TLSClient) SubscribeToAllGuildFeatures ¶
SubscribeToAllGuildFeatures subscribes to all available features for a guild
func (*TLSClient) SubscribeToGuild ¶
func (c *TLSClient) SubscribeToGuild(guildID string, options GuildSubscribeOptions) error
SubscribeToGuild subscribes to a single guild with specified features
func (*TLSClient) SubscribeToGuildChannels ¶
SubscribeToGuildChannels subscribes to specific channels with message ranges
func (*TLSClient) SubscribeToGuildMembers ¶
SubscribeToGuildMembers subscribes to specific members in a guild
func (*TLSClient) SubscribeToGuildThreads ¶
SubscribeToGuildThreads subscribes to threads in a guild
func (*TLSClient) UnsubscribeFromGuild ¶
UnsubscribeFromGuild unsubscribes from a guild by setting all features to false
type TestEvent ¶
type TestEvent struct {
Type string `json:"type,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Data map[string]interface{} `json:"data,omitempty"`
}
TestEvent represents a generic test event
type Thread ¶
type Thread struct {
ID string `json:"id"`
GuildID string `json:"guild_id"`
ParentID string `json:"parent_id"`
OwnerID string `json:"owner_id"`
Name string `json:"name"`
Type int `json:"type"`
LastMessageID *string `json:"last_message_id"`
MessageCount int `json:"message_count"`
MemberCount int `json:"member_count"`
RateLimitPerUser int `json:"rate_limit_per_user"`
Flags int `json:"flags"`
TotalMessageSent int `json:"total_message_sent"`
AppliedTags []string `json:"applied_tags"`
MemberIDsPreview []string `json:"member_ids_preview"`
ThreadMetadata *ThreadMetadata `json:"thread_metadata"`
Member *ThreadMember `json:"member,omitempty"`
}
Thread represents a Discord thread channel
type ThreadDeleteEvent ¶
type ThreadDeleteEvent struct {
ID string `json:"id"`
GuildID string `json:"guild_id"`
ParentID string `json:"parent_id"`
Type int `json:"type"`
}
ThreadDeleteEvent represents a thread deletion
type ThreadEvent ¶
type ThreadEvent struct {
ID string `json:"id"`
Type int `json:"type"`
GuildID string `json:"guild_id"`
ParentID string `json:"parent_id"`
OwnerID string `json:"owner_id"`
Name string `json:"name"`
LastMessageID *string `json:"last_message_id"`
ThreadMetadata ThreadMetadata `json:"thread_metadata"`
MessageCount int `json:"message_count"`
MemberCount int `json:"member_count"`
RateLimitPerUser int `json:"rate_limit_per_user"`
Flags int `json:"flags"`
TotalMessageSent int `json:"total_message_sent,omitempty"`
AppliedTags []string `json:"applied_tags,omitempty"`
NewlyCreated bool `json:"newly_created,omitempty"`
MemberIDsPreview []string `json:"member_ids_preview,omitempty"`
}
GuildMemberEvent represents guild member related events
type ThreadListResponse ¶
type ThreadListResponse struct {
Threads []Thread `json:"threads"`
Members []ThreadMember `json:"members"`
HasMore bool `json:"has_more"`
}
ThreadListResponse represents the response from thread list endpoints
type ThreadListSyncEvent ¶
type ThreadListSyncEvent struct {
GuildID string `json:"guild_id"`
ChannelIDs []string `json:"channel_ids,omitempty"`
Threads []ThreadEvent `json:"threads"`
Members []ThreadMember `json:"members,omitempty"`
MostRecentMessages []Message `json:"most_recent_messages"`
}
ThreadListSyncEvent represents thread list synchronization
type ThreadMember ¶
type ThreadMember struct {
ID string `json:"id,omitempty"`
UserID string `json:"user_id"`
JoinTimestamp string `json:"join_timestamp"`
Flags int `json:"flags"`
Member *Member `json:"member,omitempty"`
}
ThreadMember represents a thread member
type ThreadMemberListUpdateEvent ¶
type ThreadMemberListUpdateEvent struct {
ThreadID string `json:"thread_id"`
GuildID string `json:"guild_id"`
Members []GuildMemberEvent `json:"members"`
MemberCount int `json:"member_count"`
}
ThreadMemberListUpdateEvent represents a THREAD_MEMBER_LIST_UPDATE event Sent after subscribing to a thread member list
type ThreadMemberUpdateEvent ¶
type ThreadMemberUpdateEvent struct {
ID string `json:"id"`
UserID string `json:"user_id"`
JoinTimestamp string `json:"join_timestamp"`
Flags int `json:"flags"`
GuildID string `json:"guild_id"`
}
ThreadMemberUpdateEvent represents a THREAD_MEMBER_UPDATE event Sent when the current user's thread member object is updated
type ThreadMembersUpdateEvent ¶
type ThreadMembersUpdateEvent struct {
ID string `json:"id"`
GuildID string `json:"guild_id"`
MemberCount int `json:"member_count"`
AddedMembers []ThreadMember `json:"added_members,omitempty"`
RemovedMemberIDs []string `json:"removed_member_ids,omitempty"`
}
ThreadMembersUpdateEvent represents a THREAD_MEMBERS_UPDATE event Sent when members are added or removed from a thread
type ThreadMetadata ¶
type ThreadMetadata struct {
Archived bool `json:"archived"`
AutoArchiveDuration int `json:"auto_archive_duration"`
ArchiveTimestamp string `json:"archive_timestamp"`
Locked bool `json:"locked"`
Invitable bool `json:"invitable,omitempty"`
CreateTimestamp string `json:"create_timestamp,omitempty"`
}
ThreadMetadata represents thread metadata
type TypingStartEvent ¶
type TypingStartEvent struct {
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id,omitempty"`
UserID string `json:"user_id"`
Timestamp int64 `json:"timestamp"`
Member *Member `json:"member,omitempty"`
}
TypingStartEvent represents a typing start event
type User ¶
type User struct {
ID string `json:"id"`
Username string `json:"username"`
GlobalName string `json:"global_name"`
Discriminator string `json:"discriminator"`
Avatar string `json:"avatar"`
Bot bool `json:"bot"`
System bool `json:"system"`
Email string `json:"email"`
Verified bool `json:"verified"`
Phone string `json:"phone"`
}
User represents a Discord user
type UserNoteUpdateEvent ¶
UserNoteUpdateEvent represents user note updates
type VoiceState ¶
type VoiceState struct {
GuildID *string `json:"guild_id,omitempty"`
ChannelID *string `json:"channel_id"`
UserID string `json:"user_id"`
Member *Member `json:"member,omitempty"`
SessionID string `json:"session_id"`
Deaf bool `json:"deaf"`
Mute bool `json:"mute"`
SelfDeaf bool `json:"self_deaf"`
SelfMute bool `json:"self_mute"`
SelfStream bool `json:"self_stream"`
SelfVideo bool `json:"self_video"`
Suppress bool `json:"suppress"`
RequestToSpeakTimestamp *string `json:"request_to_speak_timestamp"`
}
VoiceState represents voice state information
type VoiceStateEvent ¶
type VoiceStateEvent struct {
GuildID string `json:"guild_id,omitempty"`
ChannelID string `json:"channel_id"`
UserID string `json:"user_id"`
Member *Member `json:"member,omitempty"`
SessionID string `json:"session_id"`
Deaf bool `json:"deaf"`
Mute bool `json:"mute"`
SelfDeaf bool `json:"self_deaf"`
SelfMute bool `json:"self_mute"`
SelfStream bool `json:"self_stream"`
SelfVideo bool `json:"self_video"`
Suppress bool `json:"suppress"`
RequestToSpeakTimestamp string `json:"request_to_speak_timestamp"`
}
VoiceStateEvent represents voice state updates
type WebSocketEvent ¶
type WebSocketEvent struct {
Op int `json:"op"`
Data json.RawMessage `json:"d"`
Type string `json:"t"`
}
WebSocketEvent represents a Discord WebSocket event
type WebSocketMessageEvent ¶
type WebSocketMessageEvent struct {
Message Message `json:"message"`
}
WebSocketMessageEvent represents a message event
type WebSocketRateLimiter ¶
type WebSocketRateLimiter struct {
// contains filtered or unexported fields
}
WebSocket Rate Limiter for outgoing messages (120 per 60 seconds)
func NewWebSocketRateLimiter ¶
func NewWebSocketRateLimiter() *WebSocketRateLimiter
NewWebSocketRateLimiter creates a rate limiter for WebSocket messages (110/60s as per discord.py-self)
func (*WebSocketRateLimiter) TakeToken ¶
func (rl *WebSocketRateLimiter) TakeToken() bool
TakeToken attempts to take a token for rate limiting
type WebSocketReactionEvent ¶
type WebSocketReactionEvent struct {
UserID string `json:"user_id"`
ChannelID string `json:"channel_id"`
MessageID string `json:"message_id"`
Emoji struct {
Name string `json:"name"`
} `json:"emoji"`
GuildID string `json:"guild_id"`
}
WebSocketReactionEvent represents a reaction event
type WebSocketReadyEvent ¶
type WebSocketReadyEvent struct {
User User `json:"user"`
Guilds []Guild `json:"guilds"`
Session string `json:"session_id"`
}
WebSocketReadyEvent represents the ready event data
type WebSocketRelationshipEvent ¶
WebSocketRelationshipEvent represents a relationship event
type WebSocketTypingEvent ¶
type WebSocketTypingEvent struct {
UserID string `json:"user_id"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
}
WebSocketTypingEvent represents a typing event
type WebSocketVoiceStateEvent ¶
type WebSocketVoiceStateEvent struct {
UserID string `json:"user_id"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
}
WebSocketVoiceStateEvent represents a voice state event