目录

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.

关于
81.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号