gatewayshard

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 18 Imported by: 0

README

Shard

Basic shard implementation utilizing the discordgateway 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 *discordgateway.GatewayState
	// contains filtered or unexported fields
}

func NewShard

func NewShard(shardID discordgateway.ShardID, botToken string, handler discordgateway.Handler, options ...discordgateway.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=9"                 => invalid
"wss://gateway.discord.gg/?v=9&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 discordgateway.IdentifyConnectionProperties

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

	CommandRateLimitChan <-chan int
	IdentifyRateLimiter  discordgateway.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

Jump to

Keyboard shortcuts

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