Documentation ¶
Overview ¶
Package gateway allows you to communicate with Discord.
We use pre-allocated buffers to prevent future allocations. You can adjust them using options.
Each gateway is limited to ONE data handler ¶
WARNING: Payload pointer that is passed as first data handler argument is SHARED. This means that the gateway uses it for every message that comes through the websocket, and DO NOT SHARE this pointer to another thread (goroutine). Payload processing from A to Z must be synchronous for gateway to wait when payload is free to be reused.
Index ¶
- func PayloadTo[V any](p *Payload) (x V, err error)
- type ChangeVoiceStateOptions
- type ChannelPinsUpdateEvent
- type Gateway
- func (g *Gateway) ChangeVoiceState(opts ChangeVoiceStateOptions) error
- func (g *Gateway) Connect(ctx context.Context) (err error)
- func (g *Gateway) Disconnect(code websocket.StatusCode)
- func (g *Gateway) EventChannel() *broadcaster.Group[events.Event]
- func (g *Gateway) OnData(fn func(data *Payload))
- func (g *Gateway) Presence() PresenceSet
- func (g *Gateway) Reconnect(ctx context.Context, resume bool) (err error)
- func (g *Gateway) RequestMembers(ctx context.Context, opts RequestMembers) (members []discord.MemberWithUser, presences []discord.BasePresence, err error)
- type GuildBanEvent
- type GuildEmojisUpdateEvent
- type GuildRoleDeleteEvent
- type GuildRoleEvent
- type GuildScheduledUserEvent
- type Identify
- type IdentifyProperties
- type IntegrationDeleteEvent
- type InviteCreateEvent
- type InviteDeleteEvent
- type MessageDeleteEvent
- type MessageReactionAddEvent
- type MessageReactionRemoveAllEmojiEvent
- type MessageReactionRemoveAllEvent
- type MessageReactionRemoveEvent
- type OpCode
- type Option
- type Options
- type Payload
- type PresenceSet
- type PresenceUpdate
- type ReadyEvent
- type RequestMembers
- type RequestMembersResponse
- type Shard
- type ShardStatus
- type ThreadListSyncEvent
- type ThreadMembersUpdateEvent
- type TypingStartEvent
- type UnavailableGuild
- type VoiceServerUpdateEvent
- type VoiceStateUpdateEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ChangeVoiceStateOptions ¶
type ChannelPinsUpdateEvent ¶
type Gateway ¶
func (*Gateway) ChangeVoiceState ¶
func (g *Gateway) ChangeVoiceState(opts ChangeVoiceStateOptions) error
ChangeVoiceState method will send OP4 Voice State Update to the gateway.
You have to listen for VoiceStateUpdate and VoiceServerUpdate events by yourself or use a wrapper built-in to client package (client.ChangeVoiceState)
func (*Gateway) Disconnect ¶
func (g *Gateway) Disconnect(code websocket.StatusCode)
func (*Gateway) EventChannel ¶
func (g *Gateway) EventChannel() *broadcaster.Group[events.Event]
func (*Gateway) Presence ¶
func (g *Gateway) Presence() PresenceSet
func (*Gateway) RequestMembers ¶
func (g *Gateway) RequestMembers(ctx context.Context, opts RequestMembers) (members []discord.MemberWithUser, presences []discord.BasePresence, err error)
type GuildBanEvent ¶
type GuildEmojisUpdateEvent ¶
type GuildRoleDeleteEvent ¶
type GuildRoleDeleteEvent struct { GuildID snowflake.ID `json:"guild_id"` RoleID snowflake.ID `json:"role_id"` }
type GuildRoleEvent ¶
type GuildScheduledUserEvent ¶
type GuildScheduledUserEvent struct { EventID snowflake.ID `json:"guild_scheduled_event_id"` UserID snowflake.ID `json:"user_id"` GuildID snowflake.ID `json:"guild_id"` }
type IdentifyProperties ¶
type IntegrationDeleteEvent ¶
type IntegrationDeleteEvent struct { ID snowflake.ID `json:"id"` GuildID snowflake.ID `json:"guild_id"` ApplicationID snowflake.ID `json:"application_id"` }
type InviteCreateEvent ¶
type InviteCreateEvent struct { CreatedAt timeconv.Timestamp `json:"created_at"` Code string `json:"code"` Inviter discord.User `json:"inviter"` TargetUser discord.User `json:"target_user"` ChannelID snowflake.ID `json:"channel_id"` GuildID snowflake.ID `json:"guild_id"` MaxAge int `json:"max_age"` MaxUses int `json:"max_uses"` TargetType int `json:"target_type"` Temporary bool `json:"temporary"` }
type InviteDeleteEvent ¶
type InviteDeleteEvent struct { Code string `json:"code"` ChannelID snowflake.ID `json:"channel_id"` GuildID snowflake.ID `json:"guild_id"` }
type MessageDeleteEvent ¶
type MessageDeleteEvent struct { ChannelID snowflake.ID `json:"channel_id"` GuildID snowflake.ID `json:"guild_id"` ID snowflake.ID `json:"id"` }
func (MessageDeleteEvent) Message ¶
func (v MessageDeleteEvent) Message(api discord.ClientQuery) (*discord.Message, error)
type MessageReactionAddEvent ¶
type MessageReactionAddEvent struct { Member *discord.MemberWithUser `json:"member"` MessageReactionRemoveEvent }
type MessageReactionRemoveAllEvent ¶
type MessageReactionRemoveAllEvent struct { ChannelID snowflake.ID `json:"channel_id"` GuildID snowflake.ID `json:"guild_id"` MessageID snowflake.ID `json:"message_id"` }
type MessageReactionRemoveEvent ¶
type MessageReactionRemoveEvent struct { Emoji discord.Emoji `json:"emoji"` UserID snowflake.ID `json:"user_id"` ChannelID snowflake.ID `json:"channel_id"` GuildID snowflake.ID `json:"guild_id"` MessageID snowflake.ID `json:"message_id"` }
func (MessageReactionRemoveEvent) InGuild ¶
func (v MessageReactionRemoveEvent) InGuild() bool
func (MessageReactionRemoveEvent) User ¶
func (v MessageReactionRemoveEvent) User(api discord.ClientQuery) (*discord.User, error)
type Option ¶
type Option func(v *Options)
func WithApiClient ¶
func WithBufferSize ¶
func WithIntents ¶
func WithLogger ¶
func WithProperties ¶
func WithProperties(props IdentifyProperties) Option
type PresenceSet ¶
type PresenceSet interface { Set(status discord.PresenceStatus, ac discord.Activity) SetCustom(data PresenceUpdate) }
type PresenceUpdate ¶
type ReadyEvent ¶
type RequestMembers ¶
type RequestMembersResponse ¶
type RequestMembersResponse struct { Nonce string `json:"nonce"` Members []discord.MemberWithUser `json:"members"` NotFound []snowflake.ID `json:"not_found"` Presences []discord.Presence `json:"presences"` ChunkIndex int `json:"chunk_index"` ChunkCount int `json:"chunk_count"` GuildID snowflake.ID `json:"guild_id"` }
type Shard ¶
type Shard struct {
// contains filtered or unexported fields
}
func (*Shard) LatencyHistory ¶
func (*Shard) SetStatus ¶
func (v *Shard) SetStatus(status ShardStatus)
func (*Shard) Status ¶
func (v *Shard) Status() ShardStatus
type ShardStatus ¶
type ShardStatus uint8
const ( ShardStatusDisconnected ShardStatus = iota + 1 ShardStatusConnected )
type ThreadListSyncEvent ¶
type ThreadListSyncEvent struct { ChannelIDs []snowflake.ID `json:"channel_ids"` Threads []discord.Channel `json:"threads"` Members []discord.ThreadMember `json:"members"` GuildID snowflake.ID `json:"guild_id"` }
type ThreadMembersUpdateEvent ¶
type ThreadMembersUpdateEvent struct { AddedMembers []discord.ThreadMember `json:"added_members"` RemovedMemberIDs []snowflake.ID `json:"removed_member_ids"` ID snowflake.ID `json:"id"` GuildID snowflake.ID `json:"guild_id"` MemberCount int `json:"member_count"` }
type TypingStartEvent ¶
type UnavailableGuild ¶
type UnavailableGuild struct {}
type VoiceServerUpdateEvent ¶
type VoiceStateUpdateEvent ¶
type VoiceStateUpdateEvent = discord.VoiceState