gateway

package
v0.6.11 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	LargeThreshold: 50,
	GatewayIntents: discord.GatewayIntentsDefault,
	Compress:       true,
	OS:             info.OS,
	Browser:        info.Name,
	Device:         info.Name,
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger            log.Logger
	EventHandlerFunc  EventHandlerFunc
	LargeThreshold    int
	GatewayIntents    discord.GatewayIntents
	Compress          bool
	RateLimiter       grate.Limiter
	RateLimiterConfig *grate.Config
	Presence          *discord.UpdatePresenceCommandData
	OS                string
	Browser           string
	Device            string
}

func (*Config) Apply

func (c *Config) Apply(opts []ConfigOpt)

type ConfigOpt

type ConfigOpt func(config *Config)

func WithBrowser

func WithBrowser(browser string) ConfigOpt

func WithCompress

func WithCompress(compress bool) ConfigOpt

func WithDevice

func WithDevice(device string) ConfigOpt

func WithGatewayIntents

func WithGatewayIntents(gatewayIntents ...discord.GatewayIntents) ConfigOpt

func WithLargeThreshold

func WithLargeThreshold(largeThreshold int) ConfigOpt

func WithOS

func WithOS(os string) ConfigOpt

func WithPresence

func WithPresence(presence discord.UpdatePresenceCommandData) ConfigOpt

func WithRateLimiter

func WithRateLimiter(rateLimiter grate.Limiter) ConfigOpt

func WithRateLimiterConfig

func WithRateLimiterConfig(rateLimiterConfig grate.Config) ConfigOpt

func WithRateLimiterConfigOpts

func WithRateLimiterConfigOpts(opts ...grate.ConfigOpt) ConfigOpt

type EventHandlerFunc

type EventHandlerFunc func(gatewayEventType discord.GatewayEventType, sequenceNumber int, payload io.Reader)

type Gateway

type Gateway interface {
	Logger() log.Logger
	Config() Config
	ShardID() int
	ShardCount() int
	Open(ctx context.Context) error
	Close(ctx context.Context) error
	Status() Status
	Send(ctx context.Context, command discord.GatewayCommand) error
	Latency() time.Duration
}

Gateway is what is used to connect to discord

func New

func New(token string, url string, shardID int, shardCount int, eventHandlerFunc EventHandlerFunc, config *Config) Gateway

type Status

type Status int

Status is the state that the client is currently in

const (
	StatusUnconnected Status = iota
	StatusConnecting
	StatusReconnecting
	StatusIdentifying
	StatusWaitingForHello
	StatusWaitingForReady
	StatusWaitingForGuilds
	StatusReady
	StatusDisconnected
	StatusResuming
)

Indicates how far along the client is to connecting

func (Status) IsConnected

func (s Status) IsConnected() bool

IsConnected returns whether you can send payloads to the Gateway

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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