• Stars
    star
    424
  • Rank 102,329 (Top 3 %)
  • Language
    Go
  • License
    ISC License
  • Created almost 5 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Golang library and framework for the Discord API.

arikawa

 Pipeline Status  Report Card      Godoc Reference  Examples         Discord Gophers  Hime Arikawa

A Golang library for the Discord API.

Library Highlights

  • More modularity with components divided up into independent packages, such as the API client and the Websocket Gateway being fully independent.
  • Clear separation of models: API and Gateway models are never mixed together so to not be confusing.
  • Extend and intercept Gateway events, allowing for use cases such as reading deleted messages.
  • Pluggable Gateway cache allows for custom caching implementations such as Redis, automatically falling back to the API if needed.
  • Typed Snowflakes make it much harder to accidentally use the wrong ID (e.g. it is impossible to use a channel ID as a message ID).
  • Working user account support, with much of them in ningen. Please do not use this for self-botting, as that is against Discord's ToS.

Examples

Commands (Hybrid)

commands-hybrid is an alternative variant of commands, where the program permits being hosted either as a Gateway-based daemon or as a web server using the Interactions Webhook API.

Both examples demonstrate adding interaction commands into the bot as well as an example of routing those commands to be executed.

Simple

Simple bot example without any state. All it does is logging messages sent into the console. Run with BOT_TOKEN="TOKEN" go run .. This example only demonstrates the most simple needs; in most cases, bots should use the state or the bot router.

Note that Discord discourages use of bots that do not use the interactions API, meaning that this example should not be used for bots.

Undeleter

A slightly more complicated example. This bot uses a local state to cache everything, including messages. It detects when someone deletes a message, logging the content into the console.

This example demonstrates the PreHandler feature of the state library. PreHandler calls all handlers that are registered (separately from the session), calling them before the state is updated.

Note that Discord discourages use of bots that do not use the interactions API, meaning that this example should not be used for bots.

Bare Minimum Bot Example

The least amount of code recommended to have a bot that responds to a /ping.

package main

import (
	"context"
	"log"
	"os"

	"github.com/diamondburned/arikawa/v3/api"
	"github.com/diamondburned/arikawa/v3/api/cmdroute"
	"github.com/diamondburned/arikawa/v3/gateway"
	"github.com/diamondburned/arikawa/v3/state"
	"github.com/diamondburned/arikawa/v3/utils/json/option"
)

var commands = []api.CreateCommandData{{Name: "ping", Description: "Ping!"}}

func main() {
	r := cmdroute.NewRouter()
	r.AddFunc("ping", func(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
		return &api.InteractionResponseData{Content: option.NewNullableString("Pong!")}
	})

	s := state.New("Bot " + os.Getenv("BOT_TOKEN"))
	s.AddInteractionHandler(r)
	s.AddIntents(gateway.IntentGuilds)

	if err := cmdroute.OverwriteCommands(s, commands); err != nil {
		log.Fatalln("cannot update commands:", err)
	}

	if err := s.Connect(context.TODO()); err != nil {
		log.Println("cannot connect:", err)
	}
}

Testing

The package includes integration tests that require $BOT_TOKEN. To run these tests, do:

export BOT_TOKEN="<BOT_TOKEN>"
go test -tags integration -race ./...

More Repositories

1

dissent

Tiny Discord app
Go
1,128
star
2

gtkcord3

A Gtk3 Discord client in Golang
Go
632
star
3

gotk4

Autogenerated GTK4 bindings for Go
Go
321
star
4

gotktrix

Matrix client in Go and GTK4
Go
298
star
5

6cord

Mirrored from GitLab
Go
153
star
6

gotk4-examples

Examples for writing GTK4 applications in Go
Go
56
star
7

slemmy

Lemmy client in Svelte
Svelte
48
star
8

cchat-gtk

Gtk frontend for cchat.
Go
37
star
9

discordlogin

An automated Discord token grabber, for use with gtkcord3
Go
33
star
10

libdb.so

Homepage for libdb.so
Go
24
star
11

kaicord

Minimal Discord client for KaiOS 3.x.
TypeScript
23
star
12

cchat

A set of stabilized interfaces for cchat implementations, joining the backend and frontend together.
Go
23
star
13

aqours

A Gtk music player
Go
22
star
14

gotk4-adwaita

Autogenerated Adwaita bindings for Go
Go
21
star
15

tcell-sixel

Proof-of-concept SIXEL in tcell
Go
18
star
16

gotkit

gotkit is a set of useful GTK4 components and functions that will aid in developing certain specific types of applications.
Go
17
star
17

hrt

HTTP routing with types
Go
16
star
18

dcfs

Discord Client as a File System
Go
14
star
19

handy

A Golang binding for libhandy
Go
13
star
20

led-skirt

Source code for the LED strip and Xiao RP2040 microcontroller that goes in my miniskirt.
Go
11
star
21

dnsmill

Declaratively set your DNS records with dnsmill, powered by libdns.
Go
11
star
22

sysmet

Daemonless server metrics collector and frontend.
Go
10
star
23

go-buttplug

A Go library for the Intiface Websocket API, which wraps the buttplug.io protocol.
Go
9
star
24

rfrouter

Reflection-based command router for Discordgo
Go
9
star
25

sfmatch

A library that allows matching input strings into structs using regex matches.
Go
8
star
26

catnip-gtk

catnip gtk frontend
Go
8
star
27

go-mommy

cargo-mommy's library in Go
Go
8
star
28

solar

A Go library for calculating the sunset/sunrise time from a given location.
Go
8
star
29

saq

A toolchain-agnostic live reload tool that supports automatic reloading of the browser when a file is changed.
Go
8
star
30

cchat-discord

Discord service backend for cchat
Go
8
star
31

ningen

Abstracted helpful functions and packages to aid in Discord client development.
Go
7
star
32

smolboard

A small booru clone in Go
Go
6
star
33

zybooks-mcq

Script to bruteforce Zybooks MCQ questions
JavaScript
6
star
34

keypounder

๐Ÿ˜ณ๐Ÿ˜ณ๐Ÿ˜ณ
Go
6
star
35

disblob

Blob emoji CSS for Discord.
Go
6
star
36

diamondburned

me
Shell
6
star
37

manjarno

so you're using manjaro huh?
6
star
38

wipe-discord

TUI application to erase Discord messages
Go
6
star
39

discord-export-messages

Tool to export Discord messages to a file in Markdown or JSON format. It is intended to be shared via GitHub Gists.
Go
6
star
40

gofan

Small fan control program using curves
Go
5
star
41

go-fanbox

Pixiv Fanbox library and tools
Go
5
star
42

leavemealone

Leave Discord servers using the folder names.
Go
5
star
43

gotk4-nix

Nix development and build utilities for gotk4 development.
Nix
5
star
44

acm-aws

Terraform deployment files for acmCSUF
Nix
5
star
45

action-upload-release

A small GitHub Action to upload build artifacts to releases.
Shell
5
star
46

onlygithub

Go
5
star
47

go-workshop

Go workshop slides and examples for ACM at CSUF.
Go
5
star
48

jotup

Extensible Markdown editor in GTK4
Go
5
star
49

fmtchat

A Discord chat log formatter
Go
5
star
50

goprofgen

Shell script to generate Go's HTTP profiling boilerplate
Shell
5
star
51

distant-front

Distance Server frontend
Go
5
star
52

hrtclicker

HRT reminder app bridged via gotify
TypeScript
5
star
53

caddy-imagebrowser

Image browser template for Caddy
HTML
4
star
54

apislurp

A small Discord documentation parser.
Go
4
star
55

tblog

A simple blog generator made to be forked.
Go
4
star
56

hugui

Simple Hugo GUI
Go
4
star
57

real6cord

6cord with actual SIXEL, a toy project
Go
4
star
58

oggreader

Tiny Ogg packet decoder
Go
4
star
59

libwebring

A tiny JavaScript library for adding a webring to your website.
TypeScript
4
star
60

ghproxy

A GitHub Proxy for a single user.
Go
4
star
61

chatkit

chatkit provides a variety of useful widgets for making any chat application in GTK4.
Go
4
star
62

gomblog

Main blog generator for blog.arikawa-hi.me
Shell
4
star
63

vocalcord

Go
4
star
64

comd

comd implements a Command Daemon that listens for HTTP requests to execute commands.
Go
4
star
65

ctxt

Package ctxt provides a way to store and retrieve values from a context using the type of the value as a key.
Go
4
star
66

acmregister

ACM register bot
Go
3
star
67

screenmap

Fullscreen borderless image viewer
Go
3
star
68

nix-user-chroot

Rewrite of nix-user-chroot in Go
Go
3
star
69

nix-search

A Nix-channel-compatible package search
Go
3
star
70

bmp-stream

Experiments with FFmpeg and GtkVideo
Go
3
star
71

persist

Package persist provides a basic type-safe map that persists to disk.
Go
3
star
72

aoc-2023

Advent of Code 2023 attempts
Go
3
star
73

csufbot

An unofficial Discord bot for CSU Fullerton students to organize their own Discord servers.
Go
3
star
74

layover-party-backend

Python
3
star
75

mass-shootings-count

Website that shows X days since last mass shooting in the US.
Go
3
star
76

shittercord

Mirrored from GitLab
Go
3
star
77

gotk-layer-shell

Gtk3 Layer Shell bindings for Go and Gotk3
Go
3
star
78

gimp-rpc-linux

GIMP Rich Presence support on Linux!
Python
3
star
79

prettier-gohtml-nix

Prettier with prettier-plugin-go-template baked into a Nix package.
Nix
3
star
80

nix-hash-fuzzer

Shell script to auto-parse mismatching SHA256 hashes from Nix derivations and gradually replace them, just as a human would do, but automated.
Shell
3
star
81

ffsync

Music library synchronizer and transcoder
Go
3
star
82

protocord

A prototype CLI for a tiny Discord client.
Go
2
star
83

go-lovense

A bunch of packages that aid in Go development for Lovense toys.
Go
2
star
84

typereplay

A small program that parses an input format to replay keyboard commands.
Go
2
star
85

lsoc-overlay

List Open Cameras.
Go
2
star
86

gracehttp

A small library to provide cleaner graceful HTTP shutdown.
Go
2
star
87

aqs

Anime quotes generator, used for test data.
Go
2
star
88

autograde-guard

Shell
2
star
89

sixcord

Go
2
star
90

discord-ical-srv

A Discord bot that synchronizes Discord events to a hosted iCal feed.
Go
2
star
91

ai-resume-picker

AI Resume Picker
Python
2
star
92

beehaw-health

Periodic beehaw.org health checking using GitHub Actions
Shell
2
star
93

gotk4-sourceview

Autogenerated Go bindings for GtkSourceView.
Go
2
star
94

catnip-gio

GPU-powered Music Visualizer in Go
Go
2
star
95

gosu-v2

osu! v2 API for Golang
Go
2
star
96

gotk4-webkitgtk

Autogenerated WebKitGTK bindings for Go
Go
2
star
97

bananum-taskum

BANANA TRACKER. TRACK BANANA. BE PRODUCTIVE.
Svelte
2
star
98

factl

CSU Fullerton Algorithm Competition Template Library
C++
2
star
99

dol-server

Extensible Degrees of Lewdity server in Go
Go
2
star
100

xirho-gtk

xirho GUI in GTK
Go
2
star