top
(readme.md)
# cord [![Build Status](https://travis-ci.org/WatchBeam/cord.svg?branch=master)](https://travis-ci.org/WatchBeam/cord) [![godoc reference](https://godoc.org/github.com/WatchBeam/cord?status.png)](https://godoc.org/github.com/WatchBeam/cord)

Experimental websocket client for Discord gateways. It parses events and handles gateway retrieval and reconnections transparently.

## Example

```go
package main

import (
    "fmt"
    "os"

    "github.com/WatchBeam/cord"
    "github.com/WatchBeam/cord/events"
    "github.com/WatchBeam/cord/model"
)

func main() {
    c := cord.New(os.Args[1], nil)

    c.On(events.Ready(func(r *model.Ready) {
        fmt.Printf("%+v\n", r)
    }))

    c.On(events.PresenceUpdate(func(r *model.PresenceUpdate) {
        fmt.Printf("%+v\n", r)
    }))

    for err := range c.Errs() {
        fmt.Printf("Got an error: %s", err)

        if _, isFatal := err.(cord.FatalError); isFatal {
            os.Exit(1)
        }
    }
}
```

## Development

JSON and the event handlers are auto-generated by the Makefile. Running `make` will ensure the generations are up-to-date and run all tests.

Imports 6 package(s)

  1. github.com/mailru/easyjson/jwriter
  2. github.com/WatchBeam/cord/model
  3. github.com/gorilla/websocket
  4. github.com/WatchBeam/cord/events
  5. github.com/mailru/easyjson/jlexer
  6. github.com/cenk/backoff

Test imports 3 package(s)

  1. github.com/stretchr/testify/assert
  2. github.com/stretchr/testify/suite
  3. github.com/stretchr/testify/mock