From 2e353870c1f997154d9c54bbf44ce9fc0a4e8598 Mon Sep 17 00:00:00 2001 From: rainfall Date: Sat, 2 Nov 2024 20:15:19 -0500 Subject: [PATCH] add proof of concept --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index a8b2a5b..430a6fc 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,37 @@ git clone https://github.com/yuzudev/zig-tls12 ./lib/zig-tls12/ git clone https://github.com/jetzig-framework/zmpl.git ./lib/zmpl/ ``` or simply run ./install.sh + +# features +* idk man + +```zig +// Sample code +const Session = @import("discord.zig").Session; +const Discord = @import("discord.zig").Discord; +const Intents = Discord.Intents; +const std = @import("std"); + +const token = "Bot MTI5ODgzOTgzMDY3OTEzMDE4OA..."; + +fn message_create(message: Discord.Message) void { + // do whatever you want + std.debug.print("captured: {?s}\n", .{message.content}); +} + +pub fn main() !void { + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); + defer arena.deinit(); + const allocator = arena.allocator(); + + var handler = try Session.init(allocator, .{ + .token = token, + .intents = Intents.fromRaw(37379), + .run = Session.GatewayDispatchEvent{ .message_create = &message_create }, + }); + errdefer handler.deinit(); + + const t = try std.Thread.spawn(.{}, Session.readMessage, .{ &handler, null }); + defer t.join(); +} +```