gocord

package module
v0.0.0-...-9e7f3a9 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

README

License. Go Reference Go Report Go Version

Gocord

Gocord is a Go library forked from DisGo, that is a Discord API wrapper written in Go.

Why fork?: This project was created for internal use within the bot Digo, which was developed by Nextep to study and enhance the team's knowledge of Go. For this reason, we wanted maximum control and to ensure the library is updated as quickly as possible with the latest Discord changes. However, we didn’t want to start from scratch.

Stability

The public API of Gocord is mostly stable at this point in time. Smaller breaking changes can happen before the v1 is released.

After v1 is released breaking changes may only happen if the Discord API requires them. They tend to break their released API versions now and then. In general for every new Discord API version the major version of Gocord should be increased and with that breaking changes between non-major versions should be held to a minimum.

Documentation

Documentation is wip and can be found under

GitHub Wiki is currently under construction. We appreciate help here.

Features
Missing Features

Getting Started

Installing
$ go get github.com/nextep-community/gocord
Building a gocord Instance

Build a bot client to interact with the Discord API

package main

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

	"github.com/nextep-community/gocord"
	"github.com/nextep-community/gocord/bot"
	"github.com/nextep-community/gocord/events"
	"github.com/nextep-community/gocord/gateway"
)

func main() {
	client, err := gocord.New("token",
		// set gateway options
		bot.WithGatewayConfigOpts(
			// set enabled intents
			gateway.WithIntents(
				gateway.IntentGuilds,
				gateway.IntentGuildMessages,
				gateway.IntentDirectMessages,
			),
		),
		// add event listeners
		bot.WithEventListenerFunc(func(e *events.MessageCreate) {
			// event code here
		}),
	)
	if err != nil {
		panic(err)
	}
	// connect to the gateway
	if err = client.OpenGateway(context.TODO()); err != nil {
		panic(err)
	}

	s := make(chan os.Signal, 1)
	signal.Notify(s, syscall.SIGINT, syscall.SIGTERM)
	<-s
}
Logging

gocord uses slog for logging.

Examples

You can find examples here

There is also a bot template with commands & db here

Other interesting projects

Is a standalone audio sending node based on Lavaplayer and JDA-Audio. Which allows for sending audio without it ever reaching any of your shards. Lavalink can be used in combination with

Is a Lavalink-Client which can be used to communicate with Lavalink to play/search tracks

Other Golang Discord Libraries

Troubleshooting

TODO

Contributing

TODO

Special Thanks

We would like to thank the DisGo team and community.

License

See LICENSE for more information.

License.

Documentation

Overview

Package gocord is a collection of packages for interaction with the Discord Bot and OAuth2 API.

Discord

Package discord is a collection of structs and types of the Discord API.

Bot

Package bot connects the Gateway/Sharding, HTTPServer, Cache, Rest & Events packages into a single high level client interface.

Gateway

Package gateway is used to connect and interact with the Discord Gateway.

Sharding

Package sharding is used to connect and interact with the Discord Gateway.

Cache

Package cache provides a generic cache interface for Discord entities.

HTTPServer

Package httpserver is used to interact with the Discord outgoing webhooks for interactions.

Events

Package events provide high level events around the Discord Events.

Rest

Package rest is used to interact with the Discord REST API.

Webhook

Package webhook provides a high level client interface for interacting with Discord webhooks.

OAuth2

Package oauth2 provides a high level client interface for interacting with Discord oauth2.

Voice

Package voice provides a high level client interface for interacting with Discord voice.

Index

Constants

View Source
const (
	// Name is the library name
	Name = "gocord"
	// Module is the library module name
	Module = "github.com/nextep-community/gocord"
	// GitHub is a link to the libraries GitHub repository
	GitHub = "https://github.com/nextep-community/gocord"
)

Variables

View Source
var (
	// Version is the currently used version of gocord
	Version = getVersion()

	SemVersion = "semver:" + Version
)

Functions

func New

func New(token string, opts ...bot.ConfigOpt) (bot.Client, error)

New creates a new bot.Client with the provided token & bot.ConfigOpt(s)

Types

This section is empty.

Directories

Path Synopsis
_examples
auto_moderation command
components command
custom_cache command
echo command
handler command
oauth2 command
pagination command
ping_pong command
proxy command
sharding command
test command
threads command
verified_roles command
voice command
webhook command
internal
insecurerandstr
Package insecurerandstr is not secure
Package insecurerandstr is not secure

Jump to

Keyboard shortcuts

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