From 8749925bc395f4eb39cc17785bacf89f26b473c0 Mon Sep 17 00:00:00 2001 From: yuzu Date: Thu, 15 May 2025 17:42:11 -0500 Subject: [PATCH] fix race condition + readme update --- src/shard/shard.zig | 4 ++-- test/test.zig | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/shard/shard.zig b/src/shard/shard.zig index fb1aca4..ef1e53a 100644 --- a/src/shard/shard.zig +++ b/src/shard/shard.zig @@ -834,8 +834,8 @@ pub fn handleEvent(self: *Self, name: []const u8, payload: json.Value) !void { }; // default handler for whoever wants it - if (self.handler.any) |anyEvent| - try anyEvent(self, payload); + //if (self.handler.any) |anyEvent| + //try anyEvent(self, payload); } pub fn logif(self: *Self, comptime format: []const u8, args: anytype) void { diff --git a/test/test.zig b/test/test.zig index 75c9f27..a709567 100644 --- a/test/test.zig +++ b/test/test.zig @@ -17,15 +17,11 @@ const std = @import("std"); const Discord = @import("discord"); const Shard = Discord.Shard; -const Intents = Discord.Intents; - -const INTENTS = 53608447; var session: *Discord.Session = undefined; fn ready(_: *Shard, payload: Discord.Ready) !void { std.debug.print("logged in as {s}\n", .{payload.user.username}); - // cache demonstration TODO } fn message_create(_: *Shard, message: Discord.Message) !void { @@ -54,9 +50,21 @@ pub fn main() !void { @panic("DISCORD_TOKEN not found in environment variables"); }; + const intents = comptime blk: { + var bits: Discord.Intents = .{}; + bits.Guilds = true; + bits.GuildMessages = true; + bits.GuildMembers = true; + // WARNING: + // YOU MUST SET THIS ON DEV PORTAL + // OTHERWISE THE LIBRARY WILL CRASH + bits.MessageContent = true; + break :blk bits; + }; + try session.start(.{ + .intents = intents, .authorization = token, - .intents = Intents.fromRaw(INTENTS), .run = .{ .message_create = &message_create, .ready = &ready }, .log = .yes, .options = .{},