Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
/ cord Public archive

Experimental websocket client for Discord gateways

License

Notifications You must be signed in to change notification settings

microsoft/cord

Repository files navigation

cord Build Status godoc reference

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

Example

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.

About

Experimental websocket client for Discord gateways

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published