1
0
Fork
You've already forked discord.zig
0
forked from yuzu/discord.zig
Discord library but in beta/alpha version
  • Zig 100%
Find a file
2025年04月22日 15:32:27 +03:00
src chore: make shard logging respect session log setting 2025年04月22日 15:32:27 +03:00
test working on cache 2025年04月13日 15:34:39 -05:00
.gitignore remove lib and add .gitignore 2024年11月07日 02:30:30 -03:00
build.zig fix for allowing incremental compilation 2025年04月10日 18:44:29 -05:00
build.zig.zon add cache lmao 2025年04月13日 00:21:34 -05:00
README.md fix typo 2025年04月13日 00:23:48 -05:00

Discord.zig

A high-performance bleeding edge Discord library in Zig, featuring full API coverage, sharding support, and fine-tuned parsing

  • Sharding Support: Ideal for large bots, enabling distributed load handling.
  • 100% API Coverage & Fully Typed: Offers complete access to Discord's API with strict typing for reliable and safe code.
  • High Performance: Faster than whichever library you can name (WIP)
  • Flexible Payload Parsing: Supports payload parsing through both zlib and zstd*.
  • Proper error handling
conststd=@import("std");constDiscord=@import("discord");constShard=Discord.Shard;fnready(_:*Shard,payload:Discord.Ready)!void{std.debug.print("logged in as {s}\n",.{payload.user.username});}fnmessage_create(session:*Shard,message:Discord.Message)!void{if(std.ascii.eqlIgnoreCase(message.content.?,"!hi")){varresult=trysession.sendMessage(message.channel_id,.{.content="hello world from discord.zig",});deferresult.deinit();constm=result.value.unwrap();std.debug.print("sent: {?s}\n",.{m.content});}}pubfnmain()!void{vargpa:std.heap.GeneralPurposeAllocator(.{})=.init;constallocator=gpa.allocator();varhandler=Discord.init(allocator);deferhandler.deinit();tryhandler.start(.{.intents=Discord.Intents.fromRaw(53608447),.token=std.posix.getenv("DISCORD_TOKEN").?,.run=.{.message_create=&message_create,.ready=&ready},.cache=Discord.CacheTables.defaults(allocator),});}

Installation

// In your build.zig fileconstexe=b.addExecutable(.{.name="marin",.root_source_file=b.path("src/main.zig"),.target=target,.optimize=optimize,});constdzig=b.dependency("discord.zig",.{});exe.root_module.addImport("discord.zig",dzig.module("discord.zig"));

Warning: the library is intended to be used with the latest dev version of Zig.

contributing

Contributions are welcome! Please open an issue or pull request if you'd like to help improve the library.

general roadmap

Task Status
stablish good sharding support w buckets and worker threads
finish multi threading
finish the event coverage roadmap
proper error handling
make the library scalable with a gateway proxy
get a cool logo

missing events right now

Event Support
voice_channel_effect_send
voice_state_update
voice_server_update

http methods missing

Endpoint Support
Audit log
Automod
Guild Scheduled Event related
Guild template related
Soundboard related
Stage Instance related
Subscription related
Voice related
Webhook related