zetka

package module
v1.0.0-RC01 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 17 Imported by: 1

README

Zetka

PkgGoDev codecov

Contributor Covenant

Discord Gateway Client for Go.

TODO:
  • Map all opcodes
  • Come up with sharding strategy
  • Resiliency
    • Resuming
    • Reconnecting
  • how to do sharding like for real

Documentation

Overview

Zetka provides a minimal, fast, efficient WebSocket client for interacting with the Discord Gateway. It has no interaction with the REST API (beyond obtaining Gateway URLs.)

Example
client, err := zetka.New("foobartoken")
if err != nil {
	log.Fatal(err)
}

results := make(chan *zetka.GatewayEvent)

go func(results chan *zetka.GatewayEvent) {
	for event := range results {
		log.Println(event.Type)
	}
}(results)

if err := client.Start(context.Background(), results); err != nil {
	log.Fatal(err)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var BaseURL = "https://discord.com/api/v8"

BaseURL for Version 8

View Source
var (
	GetGatewayPath = "/gateway/bot"
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client

func New

func New(token string) (*Client, error)

New Client

func (*Client) Receive

func (c *Client) Receive(gwuri string, results chan *GatewayEvent) error

func (*Client) Start

func (c *Client) Start(ctx context.Context, results chan *GatewayEvent) error

Start will block and listen to events and pass them to the results chan. Start will return at the first error received.

type Encoding

type Encoding string
var (
	JSON Encoding = "json"
)

func (Encoding) String

func (e Encoding) String() string

type GatewayEvent

type GatewayEvent struct {
	Type     string          `json:"t"`
	Sequence int64           `json:"s"`
	OpCode   opcode.Opcode   `json:"op"`
	Data     json.RawMessage `json:"d"`
}

type Message

type Message struct {
	ID message.Snowflake `json:"id"`
}

Directories

Path Synopsis
examples
presence Module

Jump to

Keyboard shortcuts

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