Experimental websocket client for Discord gateways. It parses events and handles gateway retrieval and reconnections transparently.
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)
}
}
}
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.