Documentation ¶
Index ¶
- Constants
- Variables
- func NewCommandRateLimiter() (<-chan int, io.Closer)
- func NewIdentifyRateLimiter() (<-chan int, io.Closer)
- func NewRateLimiter(burstCapacity int, burstDuration time.Duration) (<-chan int, io.Closer)
- func ValidateDialURL(URLString string) (string, error)
- type DiscordError
- type GatewayPayload
- type GatewayState
- func (gs *GatewayState) Close() error
- func (gs *GatewayState) EventIsWhitelisted(evt event.Type) bool
- func (gs *GatewayState) HaveIdentified() bool
- func (gs *GatewayState) HaveSessionID() bool
- func (gs *GatewayState) Heartbeat(client io.Writer) error
- func (gs *GatewayState) Identify(client io.Writer) error
- func (gs *GatewayState) InvalidateSession(closeWriter io.Writer)
- func (gs *GatewayState) ProcessCloseCode(code closecode.Type, reason string, closeWriter io.Writer) error
- func (gs *GatewayState) ProcessNextMessage(pipe io.Reader, textWriter, closeWriter io.Writer) (payload *GatewayPayload, redundant bool, err error)
- func (gs *GatewayState) ProcessPayload(payload *GatewayPayload, textWriter, closeWriter io.Writer) (redundant bool, err error)
- func (gs *GatewayState) Read(client io.Reader) (*GatewayPayload, int, error)
- func (gs *GatewayState) Resume(client io.Writer) error
- func (gs *GatewayState) SessionID() string
- func (gs *GatewayState) String() string
- func (gs *GatewayState) Write(client io.Writer, opc command.Type, payload json.RawMessage) (err error)
- type Handler
- type HandlerStruct
- type Hello
- type Identify
- type IdentifyConnectionProperties
- type IdentifyRateLimiter
- type Option
- func WithCommandRateLimiter(ratelimiter <-chan int) Option
- func WithDirectMessageEvents(events ...event.Type) Option
- func WithGuildEvents(events ...event.Type) Option
- func WithIdentifyConnectionProperties(properties *IdentifyConnectionProperties) Option
- func WithIdentifyRateLimiter(ratelimiter IdentifyRateLimiter) Option
- func WithIntents(intents intent.Type) Option
- func WithSequenceNumber(seq int64) Option
- func WithSessionID(id string) Option
- func WithShardCount(count uint) Option
- func WithShardID(id ShardID) Option
- type RawMessage
- type Ready
- type Resume
- type ShardID
Constants ¶
View Source
const ( NormalCloseCode uint16 = 1000 RestartCloseCode uint16 = 1012 )
Variables ¶
View Source
var ErrIncompleteDialURL = errors.New("incomplete url is missing one or many of: 'version', 'encoding', 'scheme'")
View Source
var ErrSequenceNumberSkipped = errors.New("the sequence number increased with more than 1, events lost")
View Source
var ErrURLScheme = errors.New("url scheme was not websocket (ws nor wss)")
View Source
var ErrUnsupportedAPICodec = fmt.Errorf("only %+v is supported", supportedAPICodes)
View Source
var ErrUnsupportedAPIVersion = fmt.Errorf("only discord api version %+v is supported", supportedAPIVersions)
Functions ¶
func NewCommandRateLimiter ¶ added in v0.2.0
func NewIdentifyRateLimiter ¶ added in v0.2.0
func NewRateLimiter ¶ added in v0.2.0
func ValidateDialURL ¶ added in v0.4.0
Types ¶
type DiscordError ¶ added in v0.5.0
func (DiscordError) CanReconnect ¶ added in v0.5.0
func (c DiscordError) CanReconnect() bool
func (*DiscordError) Error ¶ added in v0.5.0
func (c *DiscordError) Error() string
type GatewayPayload ¶
type GatewayState ¶ added in v0.2.0
type GatewayState struct {
// contains filtered or unexported fields
}
GatewayState should be discarded after the connection has closed. reconnect must create a new shard instance.
func NewGatewayState ¶ added in v0.5.0
func NewGatewayState(botToken string, options ...Option) (*GatewayState, error)
func (*GatewayState) Close ¶ added in v0.2.0
func (gs *GatewayState) Close() error
func (*GatewayState) EventIsWhitelisted ¶ added in v0.5.0
func (gs *GatewayState) EventIsWhitelisted(evt event.Type) bool
func (*GatewayState) HaveIdentified ¶ added in v0.2.0
func (gs *GatewayState) HaveIdentified() bool
func (*GatewayState) HaveSessionID ¶ added in v0.2.0
func (gs *GatewayState) HaveSessionID() bool
func (*GatewayState) Heartbeat ¶ added in v0.2.0
func (gs *GatewayState) Heartbeat(client io.Writer) error
Heartbeat Close method may be used if Write fails
func (*GatewayState) Identify ¶ added in v0.2.0
func (gs *GatewayState) Identify(client io.Writer) error
Identify Close method may be used if Write fails
func (*GatewayState) InvalidateSession ¶ added in v0.2.0
func (gs *GatewayState) InvalidateSession(closeWriter io.Writer)
func (*GatewayState) ProcessCloseCode ¶ added in v0.5.0
func (gs *GatewayState) ProcessCloseCode(code closecode.Type, reason string, closeWriter io.Writer) error
ProcessCloseCode process close code sent by discord
func (*GatewayState) ProcessNextMessage ¶ added in v0.5.0
func (gs *GatewayState) ProcessNextMessage(pipe io.Reader, textWriter, closeWriter io.Writer) (payload *GatewayPayload, redundant bool, err error)
func (*GatewayState) ProcessPayload ¶ added in v0.5.0
func (gs *GatewayState) ProcessPayload(payload *GatewayPayload, textWriter, closeWriter io.Writer) (redundant bool, err error)
func (*GatewayState) Read ¶ added in v0.2.0
func (gs *GatewayState) Read(client io.Reader) (*GatewayPayload, int, error)
func (*GatewayState) Resume ¶ added in v0.2.0
func (gs *GatewayState) Resume(client io.Writer) error
Resume Close method may be used if Write fails
func (*GatewayState) SessionID ¶ added in v0.5.0
func (gs *GatewayState) SessionID() string
func (*GatewayState) String ¶ added in v0.5.0
func (gs *GatewayState) String() string
func (*GatewayState) Write ¶ added in v0.2.0
func (gs *GatewayState) Write(client io.Writer, opc command.Type, payload json.RawMessage) (err error)
type HandlerStruct ¶ added in v0.2.0
type HandlerStruct struct { ShardID Name event.Type Data RawMessage }
type Hello ¶ added in v0.5.0
type Hello struct {
HeartbeatIntervalMilli int64 `json:"heartbeat_interval"`
}
type Identify ¶ added in v0.5.0
type Identify struct { BotToken string `json:"token"` Properties interface{} `json:"properties"` Compress bool `json:"compress,omitempty"` LargeThreshold uint8 `json:"large_threshold,omitempty"` Shard [2]uint `json:"shard"` Presence interface{} `json:"presence"` Intents intent.Type `json:"intents"` }
type IdentifyConnectionProperties ¶ added in v0.5.0
type IdentifyRateLimiter ¶ added in v0.3.0
type Option ¶ added in v0.5.0
type Option func(st *GatewayState) error
Option for initializing a new gateway state. An option must be deterministic regardless of when or how many times it is executed.
func WithCommandRateLimiter ¶ added in v0.5.0
func WithDirectMessageEvents ¶ added in v0.5.0
func WithGuildEvents ¶ added in v0.5.0
func WithIdentifyConnectionProperties ¶ added in v0.5.0
func WithIdentifyConnectionProperties(properties *IdentifyConnectionProperties) Option
func WithIdentifyRateLimiter ¶ added in v0.5.0
func WithIdentifyRateLimiter(ratelimiter IdentifyRateLimiter) Option
func WithIntents ¶ added in v0.5.0
func WithSequenceNumber ¶ added in v0.5.0
func WithSessionID ¶ added in v0.5.0
func WithShardCount ¶ added in v0.5.0
func WithShardID ¶ added in v0.5.0
type RawMessage ¶
type RawMessage = json.RawMessage
Source Files ¶
Click to show internal directories.
Click to hide internal directories.