shard

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 18 Imported by: 0

README

Shard

Basic shard implementation utilizing the gateway package.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FrameError

type FrameError struct {
	Unwanted bool
	Err      error
}

func (*FrameError) Error

func (e *FrameError) Error() string

type Shard

type Shard struct {
	Conn  net.Conn
	State *gateway.GatewayState
	// contains filtered or unexported fields
}

func NewShard

func NewShard(shardID gateway.ShardID, botToken string, handler gateway.Handler, options ...gateway.Option) (*Shard, error)

func (*Shard) Close

func (s *Shard) Close() error

Close closes the shard connection, session can not be resumed.

func (*Shard) CloseWithReconnectIntent

func (s *Shard) CloseWithReconnectIntent() error

CloseWithReconnectIntent closes the shard connection, but allows the session to be resumed later on.

func (*Shard) Dial

func (s *Shard) Dial(ctx context.Context, URLString string) (connection net.Conn, err error)

Dial sets up the websocket connection before identifying with the gateway. The url must be complete and specify api version and encoding:

"wss://gateway.discord.gg/"                     => invalid
"wss://gateway.discord.gg/?v=10"                 => invalid
"wss://gateway.discord.gg/?v=10&encoding=json"   => valid

func (*Shard) EventLoop

func (s *Shard) EventLoop(ctx context.Context) error

func (*Shard) PrepareForReconnect

func (s *Shard) PrepareForReconnect() error

func (*Shard) Write

func (s *Shard) Write(op command.Type, data []byte) error

type ShardConfig

type ShardConfig struct {
	BotToken string

	ShardID             uint
	TotalNumberOfShards uint

	IdentifyProperties gateway.IdentifyConnectionProperties

	GuildEvents []event.Type
	DMEvents    []event.Type

	CommandRateLimitChan <-chan int
	IdentifyRateLimiter  gateway.IdentifyRateLimiter

	// Intents does not have to be specified as these are derived from GuildEvents
	// and DMEvents. However, you can specify intents and it will be merged with the derived intents.
	Intents intent.Type
}

type WebsocketError

type WebsocketError struct {
	Err error
}

func (*WebsocketError) Error

func (e *WebsocketError) Error() string

func (*WebsocketError) Unwrap

func (e *WebsocketError) Unwrap() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL