disgo

package module
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

README

Go Reference Go Report Go Version License Disgo Version Disgo Discord

discord gopher

disgo

disgo is a Discord API wrapper written in Go aimed to be consistent, modular, customizable and easy to use

Summary

  1. Features
  2. Missing Features
  3. Getting Started
  4. Documentation
  5. Examples
  6. Related Projects
  7. Why another library?
  8. Troubleshooting
  9. Contributing
  10. License
Features
Missing Features

Getting Started

Installing
go get github.com/DisgoOrg/disgo
Building a Disgo Instance
package main

import (
	"github.com/DisgoOrg/disgo/core/bot"
	"github.com/DisgoOrg/disgo/discord"
	"github.com/DisgoOrg/disgo/gateway"
)

func main() {
	disgo, err := bot.New("token",
		bot.WithGatewayOpts(
			gateway.WithGatewayIntents(
				discord.GatewayIntentGuilds,
				discord.GatewayIntentGuildMessages,
				discord.GatewayIntentDirectMessages,
			),
		),
	)
}
Full Ping Pong Example
package main

import (
	"os"
	"os/signal"
	"syscall"

	"github.com/DisgoOrg/disgo/core"
	"github.com/DisgoOrg/disgo/core/bot"
	"github.com/DisgoOrg/disgo/core/events"
	"github.com/DisgoOrg/disgo/discord"
	"github.com/DisgoOrg/disgo/gateway"
	"github.com/DisgoOrg/log"
)

func main() {
	disgo, err := bot.New(os.Getenv("token"),
		bot.WithGatewayOpts(
			gateway.WithGatewayIntents(
				discord.GatewayIntentGuilds,
				discord.GatewayIntentGuildMessages,
				discord.GatewayIntentDirectMessages,
			),
		),
		bot.WithCacheOpts(core.WithCacheFlags(core.CacheFlagsNone)),
		bot.WithEventListeners(&events.ListenerAdapter{
			OnMessageCreate: onMessageCreate,
		}),
	)
	if err != nil {
		log.Fatal("error while building disgo: ", err)
	}

	defer disgo.Close()

	if err = disgo.ConnectGateway(); err != nil {
		log.Fatal("errors while connecting to gateway: ", err)
	}

	log.Info("example is now running. Press CTRL-C to exit.")
	s := make(chan os.Signal, 1)
	signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
	<-s
}

func onMessageCreate(event *events.MessageCreateEvent) {
	var message string
	if event.Message.Content == "ping" {
		message = "pong"
	} else if event.Message.Content == "pong" {
		message = "ping"
	}
	if message != "" {
		_, _ = event.Message.Reply(discord.NewMessageCreateBuilder().SetContent(message).Build())
	}
}

Logging

disgo uses our own small logging lib which provides an interface you can implement. This lib also comes with a default logger which is interchangeable and based on the standard log package. You can read more about it here

Documentation

Documentation is wip and can be found under

  • Go Reference
  • Discord Documentation

Wiki is currently under construction

Examples

You can find examples under _examples

or in these projects:

Standalone audio sending node based on Lavaplayer and JDA-Audio. Allows for sending audio without it ever reaching any of your shards.

Being used in production by FredBoat, Dyno, LewdBot, and more.

Lavalink Client which can be used to communicate with LavaLink to play/search tracks

dislog

Discord webhook logger integration for logrus

Why another library?

discordgo is a great library, but it's super low level and pain disgord I don't like code gen magic arikawa v3 rewrite looks promising but when I started with disgo v2 looked kinda bad

disgo aims to be a high level library that is modular and not a pain to use.

Troubleshooting

For help feel free to open an issues or reach out on Discord

Contributing

Contributions are welcomed but for bigger changes please first reach out via Discord or create an issue to discuss your intentions and ideas.

License

Distributed under the License . See LICENSE for more information.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
bot
internal
insecurerandstr
Package insecurerandstr is not secure
Package insecurerandstr is not secure
testbot module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL