add proof of concept

This commit is contained in:
rainfall 2024-11-02 20:15:19 -05:00
parent a663e795a4
commit 2e353870c1

View File

@ -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();
}
```