Нет описания

Bruce Marriner 2af61ea2c5 First commit of Travis CI file 9 лет назад
bot a5336e53da Inital add of example bot 9 лет назад
.travis.yml 2af61ea2c5 First commit of Travis CI file 9 лет назад
LICENSE bc323b57a1 Initial commit 9 лет назад
README.md 9a9175deec Added pretty GoDoc link 9 лет назад
channel.go 05ff822438 Stop trying to fight Discord's Int's as Strings and just use strings. 9 лет назад
discord.go f4445fb782 Commented out file, as it's not being used now. 9 лет назад
guild.go 91207ece15 Large additions to REST API and Websocket API. 9 лет назад
restapi.go 91207ece15 Large additions to REST API and Websocket API. 9 лет назад
session.go a3903aaa50 Fixes to GuildRole events 9 лет назад
structs.go 91207ece15 Large additions to REST API and Websocket API. 9 лет назад
users.go 05ff822438 Stop trying to fight Discord's Int's as Strings and just use strings. 9 лет назад
util.go 2448f72489 Major rewrite of REST API to include constants for all endpoints 9 лет назад
wsapi.go 91207ece15 Large additions to REST API and Websocket API. 9 лет назад

README.md

Discordgo

Discordgo provides a mostly complete low-level Golang interface to the Discord REST and Websocket API.

GoDoc

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

  • GoDoc
  • Hand crafted documentation coming soon.

What Works

Low level functions exist for the majority of the REST and Websocket 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

  • Editing User Profile settings
  • Permissions related functions.
  • Functions for Maintenance Status
  • Voice Channel support.

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