暫無描述

Bruce Marriner 82604ee801 Removed unneeded Session variable. 9 年之前
.travis.yml 2af61ea2c5 First commit of Travis CI file 9 年之前
LICENSE bc323b57a1 Initial commit 9 年之前
README.md 9b1b8b2e5c Added Gowalker link 9 年之前
channel.go 82604ee801 Removed unneeded Session variable. 9 年之前
discord.go f4445fb782 Commented out file, as it's not being used now. 9 年之前
endpoints.go 7f4e83460d Moving endpoints to seperate file. 9 年之前
guild.go f655167761 Several updates to make library more idiomatic Go 9 年之前
restapi.go dd1d8eabbf Fixed several functions incorrectly returning an Array - THANK YOU Pikachu :) 9 年之前
session.go f655167761 Several updates to make library more idiomatic Go 9 年之前
structs.go 8ef21d2380 Fixed IDs left as ints instead of strings. THANK YOU - Pikachu 9 年之前
users.go f655167761 Several updates to make library more idiomatic Go 9 年之前
util.go f655167761 Several updates to make library more idiomatic Go 9 年之前
wsapi.go f655167761 Several updates to make library more idiomatic Go 9 年之前

README.md

Discordgo

This package provides low level bindings for the Discord REST & Websocket API in the Go Programming Language (Golang).

GoDoc Go Walker Go report Build Status

Usage Example

package main

import (
	"fmt"
	"time"

	"github.com/bwmarrin/discordgo"
)

func main() {

	var err error

	// Create a new Discord Session and set a handler for the OnMessageCreate
    // event that happens for every new message on any channel
	Session := discordgo.Session{
		OnMessageCreate: messageCreate,
	}

	// Login to the Discord server and store the authentication token
	// inside the Session
	Session.Token, err = Session.Login("coolusername", "cleverpassword")
	if err != nil {
		fmt.Println(err)
		return
	}

	// Open websocket connection
	err = Session.Open()
	if err != nil {
		fmt.Println(err)
	}

	// Do websocket handshake.
	err = Session.Handshake()
	if err != nil {
		fmt.Println(err)
	}

	// Listen for events.
	Session.Listen()
	return
}

func messageCreate(s *discordgo.Session, m discordgo.Message) {
	fmt.Printf("%25d %s %20s > %s\n", m.ChannelID, time.Now().Format(time.Stamp), m.Author.Username, m.Content)
}

Documentation

NOTICE : This library and the Discord API are unfinished. Because of that there may be major changes to library functions, constants, and structures.

  • GoDoc
  • Hand crafted documentation coming soon.

What Works

Current package provides a low level direct mapping to the majority of Discord REST and Websock API.

  • Login/Logout
  • Open/Close Websocket and listen for events.
  • Accept/Create/Delete Invites
  • Get User details (Name, ID, Settings, etc)
  • List/Create User Channels (Private Message Channels)
  • List/Create Guilds
  • List/Create Guild Channels
  • List Guild Members
  • Receive/Send Messages to Channels

What's Unfinished

  • Make changes as needed to pass GoLint, GoVet, GoCyclo, etc. (goreportcard.com)
  • Editing User Profile settings
  • Permissions related functions.
  • Functions for Maintenance Status
  • Voice Channel support.
  • Add a higher level interface with user friendly helper functions.

Credits

Special thanks goes to both the below projects who helped me get started with this project. If you're looking for alternative Golang interfaces to Discord please check both of these out.

Other Discord APIs