Documentation ¶
Index ¶
- Constants
- type A
- type B
- type Conn
- type DiscordPacket
- type ErrorUnexpectedClose
- type Event
- type EvtClient
- func (c EvtClient) AllowedToStartPulsating(serviceID uint8) bool
- func (c EvtClient) Connect() (err error)
- func (c EvtClient) Debug(v ...interface{})
- func (c EvtClient) Disconnect() (err error)
- func (c *EvtClient) Emit(command string, data interface{}) (err error)
- func (c EvtClient) Error(v ...interface{})
- func (c EvtClient) HeartbeatLatency() (duration time.Duration, err error)
- func (c EvtClient) Info(v ...interface{})
- func (c EvtClient) Receive() <-chan *DiscordPacket
- func (c *EvtClient) RegisterEvent(event string)
- func (c *EvtClient) RemoveEvent(event string)
- func (c *EvtClient) SetPresence(data interface{}) (err error)
- func (c EvtClient) StopPulsating(serviceID uint8)
- type EvtConfig
- type K
- type Link
- type UniqueStringSlice
- type VoiceClient
- func (c VoiceClient) AllowedToStartPulsating(serviceID uint8) bool
- func (c *VoiceClient) Connect() (rdy *VoiceReady, err error)
- func (c VoiceClient) Debug(v ...interface{})
- func (c VoiceClient) Disconnect() (err error)
- func (c VoiceClient) Emit(command string, data interface{}) (err error)
- func (c VoiceClient) Error(v ...interface{})
- func (c VoiceClient) HeartbeatLatency() (duration time.Duration, err error)
- func (c VoiceClient) Info(v ...interface{})
- func (c VoiceClient) Receive() <-chan *DiscordPacket
- func (c *VoiceClient) SendUDPInfo(data *VoiceSelectProtocolParams) (ret *VoiceSessionDescription, err error)
- func (c VoiceClient) StopPulsating(serviceID uint8)
- type VoiceConfig
- type VoiceReady
- type VoiceSelectProtocolParams
- type VoiceSessionDescription
- type WebsocketErr
Constants ¶
const SaveIncomingPackets = false
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscordPacket ¶ added in v0.9.0
type DiscordPacket struct { Op uint `json:"op"` Data json.RawMessage `json:"d"` SequenceNumber uint `json:"s,omitempty"` EventName string `json:"t,omitempty"` }
DiscordPacket is packets sent by Discord over the socket connection
type ErrorUnexpectedClose ¶ added in v0.8.0
type ErrorUnexpectedClose struct {
// contains filtered or unexported fields
}
func (*ErrorUnexpectedClose) Error ¶ added in v0.8.0
func (e *ErrorUnexpectedClose) Error() string
type Event ¶
Event is dispatched by the socket layer after parsing and extracting Discord data from a incoming packet. This is the data structure used by Disgord for triggering handlers and channels with an event.
type EvtClient ¶ added in v0.9.0
type EvtClient struct { ReadyCounter uint // synchronization and rate limiting K *K // contains filtered or unexported fields }
func NewEventClient ¶ added in v0.9.0
NewManager creates a new socket client manager for handling behavior and Discord events. Note that this function initiates a go routine.
func (EvtClient) AllowedToStartPulsating ¶ added in v0.9.0
AllowedToStartPulsating you must notify when you are done pulsating!
func (EvtClient) Connect ¶ added in v0.9.0
func (c EvtClient) Connect() (err error)
Connect establishes a socket connection with the Discord API
func (EvtClient) Disconnect ¶ added in v0.9.0
func (c EvtClient) Disconnect() (err error)
Disconnect disconnects the socket connection
func (EvtClient) HeartbeatLatency ¶ added in v0.9.0
HeartbeatLatency get the time diff between sending a heartbeat and Discord replying with a heartbeat ack
func (EvtClient) Receive ¶ added in v0.9.0
func (c EvtClient) Receive() <-chan *DiscordPacket
Receive returns the channel for receiving Discord packets
func (*EvtClient) RegisterEvent ¶ added in v0.9.0
RegisterEvent tells the socket layer which event types are of interest. Any event that are not registered will be discarded once the socket info is extracted from the event.
func (*EvtClient) RemoveEvent ¶ added in v0.9.0
RemoveEvent removes an event type from the registry. This will cause the event type to be discarded by the socket layer.
func (*EvtClient) SetPresence ¶ added in v0.9.3
func (EvtClient) StopPulsating ¶ added in v0.9.0
func (c EvtClient) StopPulsating(serviceID uint8)
StopPulsating stops sending heartbeats to Discord
type EvtConfig ¶ added in v0.9.0
type EvtConfig struct { // BotToken Discord bot token BotToken string Proxy proxy.Dialer // ChannelBuffer is used to set the event channel buffer ChannelBuffer uint // TrackedEvents holds a list of predetermined events that should not be ignored. // This is especially useful for creating multiple shards, to reuse the same slice TrackedEvents *UniqueStringSlice // EventChan can be used to inject a channel instead of letting the ws client construct one // useful in sharding to avoid complicated patterns to handle N channels. EventChan chan<- *Event A A Presence interface{} // Endpoint for establishing socket connection. Either endpoints, `Gateway` or `Gateway Bot`, is used to retrieve // a valid socket endpoint from Discord Endpoint string // Encoding make sure we support the correct encoding Encoding string // Version make sure we support the correct Discord version Version int // for identify packets Browser string Device string GuildLargeThreshold uint ShardCount uint DiscordPktPool *sync.Pool Logger logger.Logger SystemShutdown chan interface{} // contains filtered or unexported fields }
EvtConfig ws TODO: remove shardID, such that this struct can be reused for every shard
type K ¶ added in v0.9.0
type K struct { Release B Key interface{} }
K is used to get the Connect permission from the shard manager
type Link ¶ added in v0.9.0
Link is used to establish basic commands to create and destroy a link. See client.Disconnect() and client.Connect() for linking to the Discord servers
type UniqueStringSlice ¶ added in v0.9.0
type UniqueStringSlice struct {
// contains filtered or unexported fields
}
UniqueStringSlice a thread safe string slice that does not allow duplicate strings to be stored
func (*UniqueStringSlice) Add ¶ added in v0.9.0
func (s *UniqueStringSlice) Add(id string)
func (*UniqueStringSlice) Exists ¶ added in v0.9.0
func (s *UniqueStringSlice) Exists(id string) bool
func (*UniqueStringSlice) Len ¶ added in v0.9.0
func (s *UniqueStringSlice) Len() int
func (*UniqueStringSlice) Remove ¶ added in v0.9.0
func (s *UniqueStringSlice) Remove(id string)
type VoiceClient ¶ added in v0.9.0
type VoiceClient struct { SystemShutdown chan interface{} // contains filtered or unexported fields }
func NewVoiceClient ¶ added in v0.9.0
func NewVoiceClient(conf *VoiceConfig) (client *VoiceClient, err error)
func (VoiceClient) AllowedToStartPulsating ¶ added in v0.9.0
AllowedToStartPulsating you must notify when you are done pulsating!
func (*VoiceClient) Connect ¶ added in v0.9.0
func (c *VoiceClient) Connect() (rdy *VoiceReady, err error)
Connect establishes a socket connection with the Discord API
func (VoiceClient) Disconnect ¶ added in v0.9.0
func (c VoiceClient) Disconnect() (err error)
Disconnect disconnects the socket connection
func (VoiceClient) Emit ¶ added in v0.9.0
Emit is used by DisGord users for dispatching a socket command to the Discord Gateway.
func (VoiceClient) HeartbeatLatency ¶ added in v0.9.0
HeartbeatLatency get the time diff between sending a heartbeat and Discord replying with a heartbeat ack
func (VoiceClient) Receive ¶ added in v0.9.0
func (c VoiceClient) Receive() <-chan *DiscordPacket
Receive returns the channel for receiving Discord packets
func (*VoiceClient) SendUDPInfo ¶ added in v0.9.0
func (c *VoiceClient) SendUDPInfo(data *VoiceSelectProtocolParams) (ret *VoiceSessionDescription, err error)
func (VoiceClient) StopPulsating ¶ added in v0.9.0
func (c VoiceClient) StopPulsating(serviceID uint8)
StopPulsating stops sending heartbeats to Discord
type VoiceConfig ¶ added in v0.9.0
type VoiceConfig struct { // Guild ID to connect to GuildID snowflake.Snowflake // User ID that is connecting UserID snowflake.Snowflake // Session ID SessionID string // Token to connect with the voice websocket Token string // proxy allows for use of a custom proxy Proxy proxy.Dialer // Endpoint for establishing voice connection Endpoint string Logger logger.Logger SystemShutdown chan interface{} }
type VoiceReady ¶ added in v0.9.0
type VoiceSelectProtocolParams ¶ added in v0.9.0
type VoiceSessionDescription ¶ added in v0.9.0
type WebsocketErr ¶ added in v0.8.0
type WebsocketErr struct { ID uint // contains filtered or unexported fields }
WebsocketErr is used internally when the websocket package returns an error. It does not represent a Discord error(!)
func (*WebsocketErr) Error ¶ added in v0.8.0
func (e *WebsocketErr) Error() string