Discord bot library for the Zig Programming Language
Find a file
2026-02-04 16:25:35 -08:00
examples get modals to actually work 2026-01-21 13:07:03 -08:00
src fix application struct 2026-02-04 16:25:35 -08:00
.gitignore fixed broken stuff with the 0.15 update 2025-10-19 22:17:57 +00:00
build.zig fix application struct 2026-02-04 16:25:35 -08:00
build.zig.zon fix application struct 2026-02-04 16:25:35 -08:00
CHANGELOG.md fix application struct 2026-02-04 16:25:35 -08:00
generate_endpoint_client.zig update EndpointClient code generation to have stable order 2026-01-01 14:30:43 -08:00
LICENSE change license to LGPL 2024-09-28 10:02:37 -07:00
README.md adding the removal of logging to TODO section 2026-01-20 18:57:47 -08:00

zigcord

A Discord API for the Zig programming language.

Currently built off of Zig Version 0.15.2. If you notice that it is broken on a more recent version of Zig, please create an issue!

Including in your project

To include this in your zig project, use the Zig Package Manager:

# you can get a lock a specific version by replacing "#main" with the version number, ie "#v0.8.0"
zig fetch --save 'git+https://codeberg.org/lipfang/zigcord#main'

Then, make sure something similar to the following is in your build.zig:

    const zigcord_dependency = b.dependency("zigcord", .{});
    const zigcord_module = zigcord_dependency.module("zigcord");

    const mybot_module = b.addModule("myBot", .{
        .root_source_file = "src/main.zig",
        .imports = &.{.{ .name = "zigcord", .module = zigcord_module }},
    });
    const my_bot_exe = b.addExecutable(.{ .name = "myBot", .root_module = mybot_module });
	b.installArtifact(gateway_bot);

Feature Support

  • All Discord API features up to January 1st, 2026
  • Uses Zig 0.15.x std.Io.Reader and std.Io.Writer interfaces
  • User-installable Apps
  • Components V2
  • WebSocket Gateway Client
  • Interaction Server
  • Rest Client

Basic Usage

This project is still in early development, so formal documentation isn't made yet. but the list of curated examples are always kept up-to-date. These are located under the examples directory.

These examples are runnable with zig build examples:gateway and zig build examples:interaction (or simply zig build examples to build all examples), and then execute the example using the zig-out/bin/<examplename> executable.

Changelog

This project is still in early development, so breaking changes happen often. However, all changes are recorded in the CHANGELOG.md file, which should make upgrading versions easy.

TODO

  • Formal documentation site once the API is stabilized
  • Some way to test endpoints
  • Better error handling to allow to get a std.json.Value from http responses if we fail to parse into a static type, similar to gateway
  • Removal of logging from zigcord+weebsocket
  • HTTP Interaction Server:
    • Standalone HTTPS support (for now, you will need a reverse-proxy to provide HTTPS support)
    • Native cloud function support (i.e. Cloudflare Workers)