forked from yuzucchii/discord.zig
fix make ChannelTypes an enum
This commit is contained in:
parent
08728161dd
commit
61ab5564f0
@ -214,10 +214,12 @@ pub const FetchReq = struct {
|
|||||||
var string = std.ArrayList(u8).init(fba.allocator());
|
var string = std.ArrayList(u8).init(fba.allocator());
|
||||||
errdefer string.deinit();
|
errdefer string.deinit();
|
||||||
|
|
||||||
try json.stringify(object, .{}, string.writer());
|
try json.stringify(object, .{
|
||||||
|
.emit_null_optional_fields = true,
|
||||||
|
}, string.writer());
|
||||||
const result = try self.makeRequest(.POST, path, try string.toOwnedSlice());
|
const result = try self.makeRequest(.POST, path, try string.toOwnedSlice());
|
||||||
|
|
||||||
if (result.status != .ok)
|
if (result.status != .ok and result.status != .created and result.status != .accepted)
|
||||||
return try json_helpers.parseLeft(DiscordError, T, self.allocator, try self.body.toOwnedSlice());
|
return try json_helpers.parseLeft(DiscordError, T, self.allocator, try self.body.toOwnedSlice());
|
||||||
|
|
||||||
return try json_helpers.parseRight(DiscordError, T, self.allocator, try self.body.toOwnedSlice());
|
return try json_helpers.parseRight(DiscordError, T, self.allocator, try self.body.toOwnedSlice());
|
||||||
@ -244,7 +246,9 @@ pub const FetchReq = struct {
|
|||||||
var string = std.ArrayList(u8).init(fba.allocator());
|
var string = std.ArrayList(u8).init(fba.allocator());
|
||||||
errdefer string.deinit();
|
errdefer string.deinit();
|
||||||
|
|
||||||
try json.stringify(object, .{}, string.writer());
|
try json.stringify(object, .{
|
||||||
|
.emit_null_optional_fields = true,
|
||||||
|
}, string.writer());
|
||||||
const result = try self.makeRequestWithFiles(.POST, path, try string.toOwnedSlice(), files);
|
const result = try self.makeRequestWithFiles(.POST, path, try string.toOwnedSlice(), files);
|
||||||
|
|
||||||
if (result.status != .ok)
|
if (result.status != .ok)
|
||||||
@ -259,7 +263,9 @@ pub const FetchReq = struct {
|
|||||||
var string = std.ArrayList(u8).init(fba.allocator());
|
var string = std.ArrayList(u8).init(fba.allocator());
|
||||||
errdefer string.deinit();
|
errdefer string.deinit();
|
||||||
|
|
||||||
try json.stringify(object, .{}, string.writer());
|
try json.stringify(object, .{
|
||||||
|
.emit_null_optional_fields = true,
|
||||||
|
}, string.writer());
|
||||||
const result = try self.makeRequest(.POST, path, try string.toOwnedSlice());
|
const result = try self.makeRequest(.POST, path, try string.toOwnedSlice());
|
||||||
|
|
||||||
if (result.status != .no_content)
|
if (result.status != .no_content)
|
||||||
|
@ -24,6 +24,8 @@ const tls = std.crypto.tls;
|
|||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
const http = std.http;
|
const http = std.http;
|
||||||
|
|
||||||
|
const MAX_VALUE_LEN = 0x1000;
|
||||||
|
|
||||||
// todo use this to read compressed messages
|
// todo use this to read compressed messages
|
||||||
const zlib = @import("zlib");
|
const zlib = @import("zlib");
|
||||||
const json = std.json;
|
const json = std.json;
|
||||||
@ -199,7 +201,7 @@ inline fn _connect_ws(allocator: mem.Allocator, url: []const u8) !ws.Client {
|
|||||||
.host = url,
|
.host = url,
|
||||||
});
|
});
|
||||||
|
|
||||||
var buf: [0x1000]u8 = undefined;
|
var buf: [MAX_VALUE_LEN]u8 = undefined;
|
||||||
const host = try std.fmt.bufPrint(&buf, "host: {s}", .{url});
|
const host = try std.fmt.bufPrint(&buf, "host: {s}", .{url});
|
||||||
|
|
||||||
conn.handshake("/?v=10&encoding=json&compress=zlib-stream", .{
|
conn.handshake("/?v=10&encoding=json&compress=zlib-stream", .{
|
||||||
@ -275,7 +277,7 @@ fn readMessage(self: *Self, _: anytype) (ReadError || SendError || ReconnectErro
|
|||||||
|
|
||||||
const raw = try std.json.parseFromTokenSource(GatewayPayloadType, self.allocator, &scanner, .{
|
const raw = try std.json.parseFromTokenSource(GatewayPayloadType, self.allocator, &scanner, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x1000,
|
.max_value_len = MAX_VALUE_LEN,
|
||||||
});
|
});
|
||||||
errdefer raw.deinit();
|
errdefer raw.deinit();
|
||||||
|
|
||||||
@ -375,7 +377,7 @@ pub fn heartbeat(self: *Self, initial_jitter: f64) SendHeartbeatError!void {
|
|||||||
std.Thread.sleep(std.time.ns_per_ms * @as(u64, @intFromFloat(timeout)));
|
std.Thread.sleep(std.time.ns_per_ms * @as(u64, @intFromFloat(timeout)));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.logif("heartbeating on shard {d}", .{self.id});
|
// self.logif("heartbeating on shard {d}", .{self.id});
|
||||||
|
|
||||||
self.rw_mutex.lock();
|
self.rw_mutex.lock();
|
||||||
const last = self.heart.lastBeat;
|
const last = self.heart.lastBeat;
|
||||||
@ -486,390 +488,390 @@ pub fn handleEvent(self: *Self, name: []const u8, payload: json.Value) !void {
|
|||||||
if (mem.eql(u8, name, "READY")) if (self.handler.ready) |event| {
|
if (mem.eql(u8, name, "READY")) if (self.handler.ready) |event| {
|
||||||
const ready = try json.parseFromValue(Types.Ready, self.allocator, payload, .{
|
const ready = try json.parseFromValue(Types.Ready, self.allocator, payload, .{
|
||||||
.ignore_unknown_fields=true,
|
.ignore_unknown_fields=true,
|
||||||
.max_value_len=0x1000,
|
.max_value_len=MAX_VALUE_LEN,
|
||||||
});
|
});
|
||||||
|
|
||||||
try event(self, ready.value);
|
try event(self, ready.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "APPLICATION_COMMAND_PERMISSIONS_UPDATE")) if (self.handler.application_command_permissions_update) |event| {
|
if (mem.eql(u8, name, "APPLICATION_COMMAND_PERMISSIONS_UPDATE")) if (self.handler.application_command_permissions_update) |event| {
|
||||||
const acp = try json.parseFromValue(Types.ApplicationCommandPermissions, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const acp = try json.parseFromValue(Types.ApplicationCommandPermissions, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, acp.value);
|
try event(self, acp.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "CHANNEL_CREATE")) if (self.handler.channel_create) |event| {
|
if (mem.eql(u8, name, "CHANNEL_CREATE")) if (self.handler.channel_create) |event| {
|
||||||
const chan = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const chan = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, chan.value);
|
try event(self, chan.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "CHANNEL_UPDATE")) if (self.handler.channel_update) |event| {
|
if (mem.eql(u8, name, "CHANNEL_UPDATE")) if (self.handler.channel_update) |event| {
|
||||||
const chan = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const chan = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, chan.value);
|
try event(self, chan.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "CHANNEL_DELETE")) if (self.handler.channel_delete) |event| {
|
if (mem.eql(u8, name, "CHANNEL_DELETE")) if (self.handler.channel_delete) |event| {
|
||||||
const chan = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const chan = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, chan.value);
|
try event(self, chan.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "CHANNEL_PINS_UPDATE")) if (self.handler.channel_pins_update) |event| {
|
if (mem.eql(u8, name, "CHANNEL_PINS_UPDATE")) if (self.handler.channel_pins_update) |event| {
|
||||||
const chan_pins_update = try json.parseFromValue(Types.ChannelPinsUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const chan_pins_update = try json.parseFromValue(Types.ChannelPinsUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, chan_pins_update.value);
|
try event(self, chan_pins_update.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "ENTITLEMENT_CREATE")) if (self.handler.entitlement_create) |event| {
|
if (mem.eql(u8, name, "ENTITLEMENT_CREATE")) if (self.handler.entitlement_create) |event| {
|
||||||
const entitlement = try json.parseFromValue(Types.Entitlement, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const entitlement = try json.parseFromValue(Types.Entitlement, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, entitlement.value);
|
try event(self, entitlement.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "ENTITLEMENT_UPDATE")) if (self.handler.entitlement_update) |event| {
|
if (mem.eql(u8, name, "ENTITLEMENT_UPDATE")) if (self.handler.entitlement_update) |event| {
|
||||||
const entitlement = try json.parseFromValue(Types.Entitlement, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const entitlement = try json.parseFromValue(Types.Entitlement, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, entitlement.value);
|
try event(self, entitlement.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "ENTITLEMENT_DELETE")) if (self.handler.entitlement_delete) |event| {
|
if (mem.eql(u8, name, "ENTITLEMENT_DELETE")) if (self.handler.entitlement_delete) |event| {
|
||||||
const entitlement = try json.parseFromValue(Types.Entitlement, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const entitlement = try json.parseFromValue(Types.Entitlement, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, entitlement.value);
|
try event(self, entitlement.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "INTEGRATION_CREATE")) if (self.handler.integration_create) |event| {
|
if (mem.eql(u8, name, "INTEGRATION_CREATE")) if (self.handler.integration_create) |event| {
|
||||||
const guild_id = try json.parseFromValue(Types.IntegrationCreateUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild_id = try json.parseFromValue(Types.IntegrationCreateUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, guild_id.value);
|
try event(self, guild_id.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "INTEGRATION_UPDATE")) if (self.handler.integration_update) |event| {
|
if (mem.eql(u8, name, "INTEGRATION_UPDATE")) if (self.handler.integration_update) |event| {
|
||||||
const guild_id = try json.parseFromValue(Types.IntegrationCreateUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild_id = try json.parseFromValue(Types.IntegrationCreateUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, guild_id.value);
|
try event(self, guild_id.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "INTEGRATION_DELETE")) if (self.handler.integration_delete) |event| {
|
if (mem.eql(u8, name, "INTEGRATION_DELETE")) if (self.handler.integration_delete) |event| {
|
||||||
const data = try json.parseFromValue(Types.IntegrationDelete, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.IntegrationDelete, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "INTERACTION_CREATE")) if (self.handler.interaction_create) |event| {
|
if (mem.eql(u8, name, "INTERACTION_CREATE")) if (self.handler.interaction_create) |event| {
|
||||||
const interaction = try json.parseFromValue(Types.MessageInteraction, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const interaction = try json.parseFromValue(Types.MessageInteraction, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, interaction.value);
|
try event(self, interaction.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "INVITE_CREATE")) if (self.handler.invite_create) |event| {
|
if (mem.eql(u8, name, "INVITE_CREATE")) if (self.handler.invite_create) |event| {
|
||||||
const data = try json.parseFromValue(Types.InviteCreate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.InviteCreate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "INVITE_DELETE")) if (self.handler.invite_delete) |event| {
|
if (mem.eql(u8, name, "INVITE_DELETE")) if (self.handler.invite_delete) |event| {
|
||||||
const data = try json.parseFromValue(Types.InviteDelete, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.InviteDelete, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSAGE_CREATE")) if (self.handler.message_create) |event| {
|
if (mem.eql(u8, name, "MESSAGE_CREATE")) if (self.handler.message_create) |event| {
|
||||||
const message = try json.parseFromValue(Types.Message, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const message = try json.parseFromValue(Types.Message, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, message.value);
|
try event(self, message.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSAGE_DELETE")) if (self.handler.message_delete) |event| {
|
if (mem.eql(u8, name, "MESSAGE_DELETE")) if (self.handler.message_delete) |event| {
|
||||||
const data = try json.parseFromValue(Types.MessageDelete, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.MessageDelete, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSAGE_UPDATE")) if (self.handler.message_update) |event| {
|
if (mem.eql(u8, name, "MESSAGE_UPDATE")) if (self.handler.message_update) |event| {
|
||||||
const message = try json.parseFromValue(Types.Message, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const message = try json.parseFromValue(Types.Message, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, message.value);
|
try event(self, message.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSAGE_DELETE_BULK")) if (self.handler.message_delete_bulk) |event| {
|
if (mem.eql(u8, name, "MESSAGE_DELETE_BULK")) if (self.handler.message_delete_bulk) |event| {
|
||||||
const data = try json.parseFromValue(Types.MessageDeleteBulk, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.MessageDeleteBulk, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSAGE_REACTION_ADD")) if (self.handler.message_reaction_add) |event| {
|
if (mem.eql(u8, name, "MESSAGE_REACTION_ADD")) if (self.handler.message_reaction_add) |event| {
|
||||||
const reaction = try json.parseFromValue(Types.MessageReactionAdd, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const reaction = try json.parseFromValue(Types.MessageReactionAdd, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, reaction.value);
|
try event(self, reaction.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSAGE_REACTION_REMOVE")) if (self.handler.message_reaction_remove) |event| {
|
if (mem.eql(u8, name, "MESSAGE_REACTION_REMOVE")) if (self.handler.message_reaction_remove) |event| {
|
||||||
const reaction = try json.parseFromValue(Types.MessageReactionRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const reaction = try json.parseFromValue(Types.MessageReactionRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, reaction.value);
|
try event(self, reaction.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSAGE_REACTION_REMOVE_ALL")) if (self.handler.message_reaction_remove_all) |event| {
|
if (mem.eql(u8, name, "MESSAGE_REACTION_REMOVE_ALL")) if (self.handler.message_reaction_remove_all) |event| {
|
||||||
const data = try json.parseFromValue(Types.MessageReactionRemoveAll, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.MessageReactionRemoveAll, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSAGE_REACTION_REMOVE_EMOJI")) if (self.handler.message_reaction_remove_emoji) |event| {
|
if (mem.eql(u8, name, "MESSAGE_REACTION_REMOVE_EMOJI")) if (self.handler.message_reaction_remove_emoji) |event| {
|
||||||
const emoji = try json.parseFromValue(Types.MessageReactionRemoveEmoji, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const emoji = try json.parseFromValue(Types.MessageReactionRemoveEmoji, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, emoji.value);
|
try event(self, emoji.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_CREATE")) {
|
if (mem.eql(u8, name, "GUILD_CREATE")) {
|
||||||
const isAvailable =
|
const isAvailable =
|
||||||
try json.parseFromValue(struct { unavailable: ?bool }, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
try json.parseFromValue(struct { unavailable: ?bool }, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
if (isAvailable.value.unavailable == true) {
|
if (isAvailable.value.unavailable == true) {
|
||||||
const guild = try json.parseFromValue(Types.Guild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild = try json.parseFromValue(Types.Guild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
if (self.handler.guild_create) |event| try event(self, guild.value);
|
if (self.handler.guild_create) |event| try event(self, guild.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const guild = try json.parseFromValue(Types.UnavailableGuild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild = try json.parseFromValue(Types.UnavailableGuild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
if (self.handler.guild_create_unavailable) |event| try event(self, guild.value);
|
if (self.handler.guild_create_unavailable) |event| try event(self, guild.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_UPDATE")) if (self.handler.guild_update) |event| {
|
if (mem.eql(u8, name, "GUILD_UPDATE")) if (self.handler.guild_update) |event| {
|
||||||
const guild = try json.parseFromValue(Types.Guild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild = try json.parseFromValue(Types.Guild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, guild.value);
|
try event(self, guild.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_DELETE")) if (self.handler.guild_delete) |event| {
|
if (mem.eql(u8, name, "GUILD_DELETE")) if (self.handler.guild_delete) |event| {
|
||||||
const guild = try json.parseFromValue(Types.UnavailableGuild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild = try json.parseFromValue(Types.UnavailableGuild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, guild.value);
|
try event(self, guild.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_CREATE")) if (self.handler.guild_scheduled_event_create) |event| {
|
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_CREATE")) if (self.handler.guild_scheduled_event_create) |event| {
|
||||||
const s_event = try json.parseFromValue(Types.ScheduledEvent, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const s_event = try json.parseFromValue(Types.ScheduledEvent, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, s_event.value);
|
try event(self, s_event.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_UPDATE")) if (self.handler.guild_scheduled_event_update) |event| {
|
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_UPDATE")) if (self.handler.guild_scheduled_event_update) |event| {
|
||||||
const s_event = try json.parseFromValue(Types.ScheduledEvent, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const s_event = try json.parseFromValue(Types.ScheduledEvent, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, s_event.value);
|
try event(self, s_event.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_DELETE")) if (self.handler.guild_scheduled_event_delete) |event| {
|
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_DELETE")) if (self.handler.guild_scheduled_event_delete) |event| {
|
||||||
const s_event = try json.parseFromValue(Types.ScheduledEvent, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const s_event = try json.parseFromValue(Types.ScheduledEvent, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, s_event.value);
|
try event(self, s_event.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_USER_ADD")) if (self.handler.guild_scheduled_event_user_add) |event| {
|
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_USER_ADD")) if (self.handler.guild_scheduled_event_user_add) |event| {
|
||||||
const data = try json.parseFromValue(Types.ScheduledEventUserAdd, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.ScheduledEventUserAdd, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_USER_REMOVE")) if (self.handler.guild_scheduled_event_user_remove) |event| {
|
if (mem.eql(u8, name, "GUILD_SCHEDULED_EVENT_USER_REMOVE")) if (self.handler.guild_scheduled_event_user_remove) |event| {
|
||||||
const data = try json.parseFromValue(Types.ScheduledEventUserRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.ScheduledEventUserRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_MEMBER_ADD")) if (self.handler.guild_member_add) |event| {
|
if (mem.eql(u8, name, "GUILD_MEMBER_ADD")) if (self.handler.guild_member_add) |event| {
|
||||||
const guild_id = try json.parseFromValue(Types.GuildMemberAdd, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild_id = try json.parseFromValue(Types.GuildMemberAdd, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, guild_id.value);
|
try event(self, guild_id.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_MEMBER_UPDATE")) if (self.handler.guild_member_update) |event| {
|
if (mem.eql(u8, name, "GUILD_MEMBER_UPDATE")) if (self.handler.guild_member_update) |event| {
|
||||||
const fields = try json.parseFromValue(Types.GuildMemberUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const fields = try json.parseFromValue(Types.GuildMemberUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, fields.value);
|
try event(self, fields.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_MEMBER_REMOVE")) if (self.handler.guild_member_remove) |event| {
|
if (mem.eql(u8, name, "GUILD_MEMBER_REMOVE")) if (self.handler.guild_member_remove) |event| {
|
||||||
const user = try json.parseFromValue(Types.GuildMemberRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const user = try json.parseFromValue(Types.GuildMemberRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, user.value);
|
try event(self, user.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_MEMBERS_CHUNK")) if (self.handler.guild_members_chunk) |event| {
|
if (mem.eql(u8, name, "GUILD_MEMBERS_CHUNK")) if (self.handler.guild_members_chunk) |event| {
|
||||||
const data = try json.parseFromValue(Types.GuildMembersChunk, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.GuildMembersChunk, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_ROLE_CREATE")) if (self.handler.guild_role_create) |event| {
|
if (mem.eql(u8, name, "GUILD_ROLE_CREATE")) if (self.handler.guild_role_create) |event| {
|
||||||
const role = try json.parseFromValue(Types.GuildRoleCreate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const role = try json.parseFromValue(Types.GuildRoleCreate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, role.value);
|
try event(self, role.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_ROLE_UPDATE")) if (self.handler.guild_role_update) |event| {
|
if (mem.eql(u8, name, "GUILD_ROLE_UPDATE")) if (self.handler.guild_role_update) |event| {
|
||||||
const role = try json.parseFromValue(Types.GuildRoleUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const role = try json.parseFromValue(Types.GuildRoleUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, role.value);
|
try event(self, role.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_ROLE_DELETE")) if (self.handler.guild_role_delete) |event| {
|
if (mem.eql(u8, name, "GUILD_ROLE_DELETE")) if (self.handler.guild_role_delete) |event| {
|
||||||
const role_id = try json.parseFromValue(Types.GuildRoleDelete, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const role_id = try json.parseFromValue(Types.GuildRoleDelete, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, role_id.value);
|
try event(self, role_id.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_DELETE")) if (self.handler.guild_delete) |event| {
|
if (mem.eql(u8, name, "GUILD_DELETE")) if (self.handler.guild_delete) |event| {
|
||||||
const guild = try json.parseFromValue(Types.UnavailableGuild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild = try json.parseFromValue(Types.UnavailableGuild, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, guild.value);
|
try event(self, guild.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_BAN_ADD")) if (self.handler.guild_ban_add) |event| {
|
if (mem.eql(u8, name, "GUILD_BAN_ADD")) if (self.handler.guild_ban_add) |event| {
|
||||||
const gba = try json.parseFromValue(Types.GuildBanAddRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const gba = try json.parseFromValue(Types.GuildBanAddRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, gba.value);
|
try event(self, gba.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_BAN_REMOVE")) if (self.handler.guild_ban_remove) |event| {
|
if (mem.eql(u8, name, "GUILD_BAN_REMOVE")) if (self.handler.guild_ban_remove) |event| {
|
||||||
const gbr = try json.parseFromValue(Types.GuildBanAddRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const gbr = try json.parseFromValue(Types.GuildBanAddRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, gbr.value);
|
try event(self, gbr.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_EMOJIS_UPDATE")) if (self.handler.guild_emojis_update) |event| {
|
if (mem.eql(u8, name, "GUILD_EMOJIS_UPDATE")) if (self.handler.guild_emojis_update) |event| {
|
||||||
const emojis = try json.parseFromValue(Types.GuildEmojisUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const emojis = try json.parseFromValue(Types.GuildEmojisUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, emojis.value);
|
try event(self, emojis.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_STICKERS_UPDATE")) if (self.handler.guild_stickers_update) |event| {
|
if (mem.eql(u8, name, "GUILD_STICKERS_UPDATE")) if (self.handler.guild_stickers_update) |event| {
|
||||||
const stickers = try json.parseFromValue(Types.GuildStickersUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const stickers = try json.parseFromValue(Types.GuildStickersUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, stickers.value);
|
try event(self, stickers.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "GUILD_INTEGRATIONS_UPDATE")) if (self.handler.guild_integrations_update) |event| {
|
if (mem.eql(u8, name, "GUILD_INTEGRATIONS_UPDATE")) if (self.handler.guild_integrations_update) |event| {
|
||||||
const guild_id = try json.parseFromValue(Types.GuildIntegrationsUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild_id = try json.parseFromValue(Types.GuildIntegrationsUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, guild_id.value);
|
try event(self, guild_id.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "THREAD_CREATE")) if (self.handler.thread_create) |event| {
|
if (mem.eql(u8, name, "THREAD_CREATE")) if (self.handler.thread_create) |event| {
|
||||||
const thread = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const thread = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, thread.value);
|
try event(self, thread.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "THREAD_UPDATE")) if (self.handler.thread_update) |event| {
|
if (mem.eql(u8, name, "THREAD_UPDATE")) if (self.handler.thread_update) |event| {
|
||||||
const thread = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const thread = try json.parseFromValue(Types.Channel, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, thread.value);
|
try event(self, thread.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "THREAD_DELETE")) if (self.handler.thread_delete) |event| {
|
if (mem.eql(u8, name, "THREAD_DELETE")) if (self.handler.thread_delete) |event| {
|
||||||
const thread_data = try json.parseFromValue(Types.Partial(Types.Channel), self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const thread_data = try json.parseFromValue(Types.Partial(Types.Channel), self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, thread_data.value);
|
try event(self, thread_data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "THREAD_LIST_SYNC")) if (self.handler.thread_list_sync) |event| {
|
if (mem.eql(u8, name, "THREAD_LIST_SYNC")) if (self.handler.thread_list_sync) |event| {
|
||||||
const data = try json.parseFromValue(Types.ThreadListSync, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.ThreadListSync, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "THREAD_MEMBER_UPDATE")) if (self.handler.thread_member_update) |event| {
|
if (mem.eql(u8, name, "THREAD_MEMBER_UPDATE")) if (self.handler.thread_member_update) |event| {
|
||||||
const guild_id = try json.parseFromValue(Types.ThreadMemberUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const guild_id = try json.parseFromValue(Types.ThreadMemberUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, guild_id.value);
|
try event(self, guild_id.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "THREAD_MEMBERS_UPDATE")) if (self.handler.thread_members_update) |event| {
|
if (mem.eql(u8, name, "THREAD_MEMBERS_UPDATE")) if (self.handler.thread_members_update) |event| {
|
||||||
const data = try json.parseFromValue(Types.ThreadMembersUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.ThreadMembersUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "TYPING_START")) if (self.handler.typing_start) |event| {
|
if (mem.eql(u8, name, "TYPING_START")) if (self.handler.typing_start) |event| {
|
||||||
const data = try json.parseFromValue(Types.TypingStart, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.TypingStart, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "USER_UPDATE")) if (self.handler.user_update) |event| {
|
if (mem.eql(u8, name, "USER_UPDATE")) if (self.handler.user_update) |event| {
|
||||||
const user = try json.parseFromValue(Types.User, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const user = try json.parseFromValue(Types.User, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, user.value);
|
try event(self, user.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "PRESENCE_UPDATE")) if (self.handler.presence_update) |event| {
|
if (mem.eql(u8, name, "PRESENCE_UPDATE")) if (self.handler.presence_update) |event| {
|
||||||
const pu = try json.parseFromValue(Types.PresenceUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const pu = try json.parseFromValue(Types.PresenceUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, pu.value);
|
try event(self, pu.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSSAGE_POLL_VOTE_ADD")) if (self.handler.message_poll_vote_add) |event| {
|
if (mem.eql(u8, name, "MESSSAGE_POLL_VOTE_ADD")) if (self.handler.message_poll_vote_add) |event| {
|
||||||
const data = try json.parseFromValue(Types.PollVoteAdd, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.PollVoteAdd, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "MESSSAGE_POLL_VOTE_REMOVE")) if (self.handler.message_poll_vote_remove) |event| {
|
if (mem.eql(u8, name, "MESSSAGE_POLL_VOTE_REMOVE")) if (self.handler.message_poll_vote_remove) |event| {
|
||||||
const data = try json.parseFromValue(Types.PollVoteRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const data = try json.parseFromValue(Types.PollVoteRemove, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, data.value);
|
try event(self, data.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "WEBHOOKS_UPDATE")) if (self.handler.webhooks_update) |event| {
|
if (mem.eql(u8, name, "WEBHOOKS_UPDATE")) if (self.handler.webhooks_update) |event| {
|
||||||
const fields = try json.parseFromValue(Types.WebhookUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const fields = try json.parseFromValue(Types.WebhookUpdate, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, fields.value);
|
try event(self, fields.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "STAGE_INSTANCE_CREATE")) if (self.handler.stage_instance_create) |event| {
|
if (mem.eql(u8, name, "STAGE_INSTANCE_CREATE")) if (self.handler.stage_instance_create) |event| {
|
||||||
const stage = try json.parseFromValue(Types.StageInstance, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const stage = try json.parseFromValue(Types.StageInstance, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, stage.value);
|
try event(self, stage.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "STAGE_INSTANCE_UPDATE")) if (self.handler.stage_instance_update) |event| {
|
if (mem.eql(u8, name, "STAGE_INSTANCE_UPDATE")) if (self.handler.stage_instance_update) |event| {
|
||||||
const stage = try json.parseFromValue(Types.StageInstance, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const stage = try json.parseFromValue(Types.StageInstance, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, stage.value);
|
try event(self, stage.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "STAGE_INSTANCE_DELETE")) if (self.handler.stage_instance_delete) |event| {
|
if (mem.eql(u8, name, "STAGE_INSTANCE_DELETE")) if (self.handler.stage_instance_delete) |event| {
|
||||||
const stage = try json.parseFromValue(Types.StageInstance, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const stage = try json.parseFromValue(Types.StageInstance, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, stage.value);
|
try event(self, stage.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "AUTO_MODERATION_RULE_CREATE")) if (self.handler.auto_moderation_rule_create) |event| {
|
if (mem.eql(u8, name, "AUTO_MODERATION_RULE_CREATE")) if (self.handler.auto_moderation_rule_create) |event| {
|
||||||
const rule = try json.parseFromValue(Types.AutoModerationRule, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const rule = try json.parseFromValue(Types.AutoModerationRule, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, rule.value);
|
try event(self, rule.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "AUTO_MODERATION_RULE_UPDATE")) if (self.handler.auto_moderation_rule_update) |event| {
|
if (mem.eql(u8, name, "AUTO_MODERATION_RULE_UPDATE")) if (self.handler.auto_moderation_rule_update) |event| {
|
||||||
const rule = try json.parseFromValue(Types.AutoModerationRule, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const rule = try json.parseFromValue(Types.AutoModerationRule, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, rule.value);
|
try event(self, rule.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "AUTO_MODERATION_RULE_DELETE")) if (self.handler.auto_moderation_rule_delete) |event| {
|
if (mem.eql(u8, name, "AUTO_MODERATION_RULE_DELETE")) if (self.handler.auto_moderation_rule_delete) |event| {
|
||||||
const rule = try json.parseFromValue(Types.AutoModerationRule, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=0x1000});
|
const rule = try json.parseFromValue(Types.AutoModerationRule, self.allocator, payload, .{.ignore_unknown_fields=true, .max_value_len=MAX_VALUE_LEN});
|
||||||
|
|
||||||
try event(self, rule.value);
|
try event(self, rule.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (mem.eql(u8, name, "AUTO_MODERATION_ACTION_EXECUTION")) if (self.handler.auto_moderation_action_execution) |event| {
|
if (mem.eql(u8, name, "AUTO_MODERATION_ACTION_EXECUTION")) if (self.handler.auto_moderation_action_execution) |event| {
|
||||||
const ax = try json.parseFromValue(Types.AutoModerationActionExecution, self.allocator, payload, .{ .ignore_unknown_fields=true, .max_value_len = 0x1000,
|
const ax = try json.parseFromValue(Types.AutoModerationActionExecution, self.allocator, payload, .{ .ignore_unknown_fields=true, .max_value_len = MAX_VALUE_LEN,
|
||||||
});
|
});
|
||||||
|
|
||||||
try event(self, ax.value);
|
try event(self, ax.value);
|
||||||
|
@ -22,6 +22,10 @@ pub const PresenceStatus = enum {
|
|||||||
dnd,
|
dnd,
|
||||||
idle,
|
idle,
|
||||||
offline,
|
offline,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/user#user-object-premium-types
|
/// https://discord.com/developers/docs/resources/user#user-object-premium-types
|
||||||
@ -30,6 +34,10 @@ pub const PremiumTypes = enum {
|
|||||||
NitroClassic,
|
NitroClassic,
|
||||||
Nitro,
|
Nitro,
|
||||||
NitroBasic,
|
NitroBasic,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/user#user-object-user-flags
|
/// https://discord.com/developers/docs/resources/user#user-object-user-flags
|
||||||
@ -522,6 +530,10 @@ pub const MessageComponentTypes = enum(u4) {
|
|||||||
SelectMenuUsersAndRoles,
|
SelectMenuUsersAndRoles,
|
||||||
/// Select menu for channels
|
/// Select menu for channels
|
||||||
SelectMenuChannels,
|
SelectMenuChannels,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const TextStyles = enum(u4) {
|
pub const TextStyles = enum(u4) {
|
||||||
@ -529,6 +541,10 @@ pub const TextStyles = enum(u4) {
|
|||||||
Short = 1,
|
Short = 1,
|
||||||
/// Intended for much longer inputs
|
/// Intended for much longer inputs
|
||||||
Paragraph = 2,
|
Paragraph = 2,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/interactions/message-components#buttons-button-styles
|
/// https://discord.com/developers/docs/interactions/message-components#buttons-button-styles
|
||||||
@ -545,6 +561,10 @@ pub const ButtonStyles = enum(u4) {
|
|||||||
Link,
|
Link,
|
||||||
/// A blurple button to show a Premium item in the shop
|
/// A blurple button to show a Premium item in the shop
|
||||||
Premium,
|
Premium,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types
|
/// https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types
|
||||||
@ -555,6 +575,10 @@ pub const AllowedMentionsTypes = enum {
|
|||||||
users,
|
users,
|
||||||
/// Controls \@everyone and \@here mentions
|
/// Controls \@everyone and \@here mentions
|
||||||
everyone,
|
everyone,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types
|
/// https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types
|
||||||
@ -565,6 +589,10 @@ pub const WebhookTypes = enum(u4) {
|
|||||||
ChannelFollower,
|
ChannelFollower,
|
||||||
/// Application webhooks are webhooks used with Interactions
|
/// Application webhooks are webhooks used with Interactions
|
||||||
Application,
|
Application,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/channel#embed-object-embed-types
|
/// https://discord.com/developers/docs/resources/channel#embed-object-embed-types
|
||||||
@ -577,6 +605,10 @@ pub const EmbedTypes = enum {
|
|||||||
article,
|
article,
|
||||||
link,
|
link,
|
||||||
poll_res,
|
poll_res,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
|
/// https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
|
||||||
@ -585,6 +617,10 @@ pub const DefaultMessageNotificationLevels = enum {
|
|||||||
AllMessages,
|
AllMessages,
|
||||||
/// Members will receive notifications only for messages that \@mention them by default
|
/// Members will receive notifications only for messages that \@mention them by default
|
||||||
OnlyMentions,
|
OnlyMentions,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
|
/// https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
|
||||||
@ -595,6 +631,10 @@ pub const ExplicitContentFilterLevels = enum {
|
|||||||
MembersWithoutRoles,
|
MembersWithoutRoles,
|
||||||
/// Media content sent by all members will be scanned
|
/// Media content sent by all members will be scanned
|
||||||
AllMembers,
|
AllMembers,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/guild#guild-object-verification-level
|
/// https://discord.com/developers/docs/resources/guild#guild-object-verification-level
|
||||||
@ -609,6 +649,10 @@ pub const VerificationLevels = enum {
|
|||||||
High,
|
High,
|
||||||
/// Must have a verified phone number
|
/// Must have a verified phone number
|
||||||
VeryHigh,
|
VeryHigh,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/guild#guild-object-guild-features
|
/// https://discord.com/developers/docs/resources/guild#guild-object-guild-features
|
||||||
@ -665,6 +709,10 @@ pub const GuildFeatures = enum {
|
|||||||
RAID_ALERTS_DISABLED,
|
RAID_ALERTS_DISABLED,
|
||||||
/// Guild is using the old permissions configuration behavior
|
/// Guild is using the old permissions configuration behavior
|
||||||
APPLICATION_COMMAND_PERMISSIONS_V2,
|
APPLICATION_COMMAND_PERMISSIONS_V2,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
|
/// https://discord.com/developers/docs/resources/guild#guild-object-mfa-level
|
||||||
@ -673,6 +721,10 @@ pub const MfaLevels = enum {
|
|||||||
None,
|
None,
|
||||||
/// Guild has a 2FA requirement for moderation actions
|
/// Guild has a 2FA requirement for moderation actions
|
||||||
Elevated,
|
Elevated,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
|
/// https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
|
||||||
@ -722,6 +774,10 @@ pub const PremiumTiers = enum {
|
|||||||
Tier2,
|
Tier2,
|
||||||
/// Guild has unlocked Server Boost level 3 perks
|
/// Guild has unlocked Server Boost level 3 perks
|
||||||
Tier3,
|
Tier3,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
|
/// https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
|
||||||
@ -730,67 +786,53 @@ pub const GuildNsfwLevel = enum {
|
|||||||
Explicit,
|
Explicit,
|
||||||
Safe,
|
Safe,
|
||||||
AgeRestricted,
|
AgeRestricted,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/channel#channel-object-channel-types
|
/// https://discord.com/developers/docs/resources/channel#channel-object-channel-types
|
||||||
pub const ChannelTypes = packed struct {
|
pub const ChannelTypes = enum(u16) {
|
||||||
pub fn toRaw(self: ChannelTypes) u32 {
|
|
||||||
return @bitCast(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn fromRaw(raw: u32) ChannelTypes {
|
|
||||||
return @bitCast(raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn jsonParse(allocator: std.mem.Allocator, src: anytype, _: std.json.ParseOptions) !@This() {
|
|
||||||
const value = try std.json.innerParse(std.json.Value, allocator, src, .{
|
|
||||||
.ignore_unknown_fields = true,
|
|
||||||
.max_value_len = 0x1000,
|
|
||||||
});
|
|
||||||
if (value != .integer) @panic("Invalid value for bitfield");
|
|
||||||
|
|
||||||
return fromRaw(@intCast(value.integer));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn jsonParseFromValue(_: std.mem.Allocator, src: std.json.Value, _: std.json.ParseOptions) @This() {
|
|
||||||
if (src != .integer) @panic("Invalid value for bitfield");
|
|
||||||
return fromRaw(@intCast(src.integer));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// A text channel within a server
|
/// A text channel within a server
|
||||||
GuildText: bool = false,
|
GuildText,
|
||||||
/// A direct message between users
|
/// A direct message between users
|
||||||
DM: bool = false,
|
DM,
|
||||||
/// A voice channel within a server
|
/// A voice channel within a server
|
||||||
GuildVoice: bool = false,
|
GuildVoice,
|
||||||
/// A direct message between multiple users
|
/// A direct message between multiple users
|
||||||
GroupDm: bool = false,
|
GroupDm,
|
||||||
/// An organizational category that contains up to 50 channels
|
/// An organizational category that contains up to 50 channels
|
||||||
GuildCategory: bool = false,
|
GuildCategory,
|
||||||
/// A channel that users can follow and crosspost into their own server
|
/// A channel that users can follow and crosspost into their own server
|
||||||
GuildAnnouncement: bool = false,
|
GuildAnnouncement,
|
||||||
_pad: u4 = 0,
|
|
||||||
/// A temporary sub-channel within a GUILD_ANNOUNCEMENT channel
|
/// A temporary sub-channel within a GUILD_ANNOUNCEMENT channel
|
||||||
AnnouncementThread: bool = false,
|
AnnouncementThread = 10,
|
||||||
/// A temporary sub-channel within a GUILD_TEXT or GUILD_FORUM channel
|
/// A temporary sub-channel within a GUILD_TEXT or GUILD_FORUM channel
|
||||||
PublicThread: bool = false,
|
PublicThread,
|
||||||
/// A temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission
|
/// A temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission
|
||||||
PrivateThread: bool = false,
|
PrivateThread,
|
||||||
/// A voice channel for hosting events with an audience
|
/// A voice channel for hosting events with an audience
|
||||||
GuildStageVoice: bool = false,
|
GuildStageVoice,
|
||||||
/// A channel in a hub containing the listed servers
|
/// A channel in a hub containing the listed servers
|
||||||
GuildDirectory: bool = false,
|
GuildDirectory,
|
||||||
/// A channel which can only contains threads
|
/// A channel which can only contains threads
|
||||||
GuildForum: bool = false,
|
GuildForum,
|
||||||
/// Channel that can only contain threads, similar to GUILD_FORUM channels
|
/// Channel that can only contain threads, similar to GUILD_FORUM channels
|
||||||
GuildMedia: bool = false,
|
GuildMedia,
|
||||||
_pad1: u15 = 0,
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const OverwriteTypes = enum {
|
pub const OverwriteTypes = enum {
|
||||||
Role,
|
Role,
|
||||||
Member,
|
Member,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const VideoQualityModes = enum(u4) {
|
pub const VideoQualityModes = enum(u4) {
|
||||||
@ -798,6 +840,10 @@ pub const VideoQualityModes = enum(u4) {
|
|||||||
Auto = 1,
|
Auto = 1,
|
||||||
/// 720p
|
/// 720p
|
||||||
Full,
|
Full,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types
|
/// https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types
|
||||||
@ -808,6 +854,10 @@ pub const ActivityTypes = enum(u4) {
|
|||||||
Watching = 3,
|
Watching = 3,
|
||||||
Custom = 4,
|
Custom = 4,
|
||||||
Competing = 5,
|
Competing = 5,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/channel#message-object-message-types
|
/// https://discord.com/developers/docs/resources/channel#message-object-message-types
|
||||||
@ -849,6 +899,10 @@ pub const MessageTypes = enum(u8) {
|
|||||||
GuildIncidentReportFalseAlarm,
|
GuildIncidentReportFalseAlarm,
|
||||||
PurchaseNotification = 44,
|
PurchaseNotification = 44,
|
||||||
PollResult = 46,
|
PollResult = 46,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
|
/// https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
|
||||||
@ -857,6 +911,10 @@ pub const MessageActivityTypes = enum(u4) {
|
|||||||
Spectate = 2,
|
Spectate = 2,
|
||||||
Listen = 3,
|
Listen = 3,
|
||||||
JoinRequest = 5,
|
JoinRequest = 5,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types
|
/// https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types
|
||||||
@ -865,6 +923,10 @@ pub const StickerTypes = enum(u4) {
|
|||||||
Standard = 1,
|
Standard = 1,
|
||||||
/// a sticker uploaded to a guild for the guild's members
|
/// a sticker uploaded to a guild for the guild's members
|
||||||
Guild = 2,
|
Guild = 2,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types
|
/// https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types
|
||||||
@ -873,6 +935,10 @@ pub const StickerFormatTypes = enum(u4) {
|
|||||||
APng,
|
APng,
|
||||||
Lottie,
|
Lottie,
|
||||||
Gif,
|
Gif,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
|
/// https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
|
||||||
@ -882,6 +948,10 @@ pub const InteractionTypes = enum(u4) {
|
|||||||
MessageComponent = 3,
|
MessageComponent = 3,
|
||||||
ApplicationCommandAutocomplete = 4,
|
ApplicationCommandAutocomplete = 4,
|
||||||
ModalSubmit = 5,
|
ModalSubmit = 5,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
|
/// https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
|
||||||
@ -897,6 +967,10 @@ pub const ApplicationCommandOptionTypes = enum(u4) {
|
|||||||
Mentionable,
|
Mentionable,
|
||||||
Number,
|
Number,
|
||||||
Attachment,
|
Attachment,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
|
/// https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
|
||||||
@ -1027,17 +1101,29 @@ pub const AuditLogEvents = enum(u4) {
|
|||||||
HomeSettingsCreate = 190,
|
HomeSettingsCreate = 190,
|
||||||
/// Guild Server Guide was updated
|
/// Guild Server Guide was updated
|
||||||
HomeSettingsUpdate,
|
HomeSettingsUpdate,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ScheduledEventPrivacyLevel = enum(u4) {
|
pub const ScheduledEventPrivacyLevel = enum(u4) {
|
||||||
/// the scheduled event is only accessible to guild members
|
/// the scheduled event is only accessible to guild members
|
||||||
GuildOnly = 2,
|
GuildOnly = 2,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ScheduledEventEntityType = enum(u4) {
|
pub const ScheduledEventEntityType = enum(u4) {
|
||||||
StageInstance = 1,
|
StageInstance = 1,
|
||||||
Voice,
|
Voice,
|
||||||
External,
|
External,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ScheduledEventStatus = enum(u4) {
|
pub const ScheduledEventStatus = enum(u4) {
|
||||||
@ -1045,12 +1131,20 @@ pub const ScheduledEventStatus = enum(u4) {
|
|||||||
Active,
|
Active,
|
||||||
Completed,
|
Completed,
|
||||||
Canceled,
|
Canceled,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
|
/// https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
|
||||||
pub const TargetTypes = enum(u4) {
|
pub const TargetTypes = enum(u4) {
|
||||||
Stream = 1,
|
Stream = 1,
|
||||||
EmbeddedApplication,
|
EmbeddedApplication,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ApplicationCommandTypes = enum(u4) {
|
pub const ApplicationCommandTypes = enum(u4) {
|
||||||
@ -1062,12 +1156,20 @@ pub const ApplicationCommandTypes = enum(u4) {
|
|||||||
Message,
|
Message,
|
||||||
/// A UI-based command that represents the primary way to invoke an app's Activity
|
/// A UI-based command that represents the primary way to invoke an app's Activity
|
||||||
PrimaryEntryPoint,
|
PrimaryEntryPoint,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ApplicationCommandPermissionTypes = enum(u4) {
|
pub const ApplicationCommandPermissionTypes = enum(u4) {
|
||||||
Role = 1,
|
Role = 1,
|
||||||
User,
|
User,
|
||||||
Channel,
|
Channel,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
|
/// https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
|
||||||
@ -1331,6 +1433,10 @@ pub const GatewayCloseEventCodes = enum(u16) {
|
|||||||
InvalidIntents,
|
InvalidIntents,
|
||||||
/// You sent a disallowed intent for a [Gateway Intent](https://discord.com/developers/docs/topics/gateway#gateway-intents). You may have tried to specify an intent that you [have not enabled or are not approved for](https://discord.com/developers/docs/topics/gateway#privileged-intents).
|
/// You sent a disallowed intent for a [Gateway Intent](https://discord.com/developers/docs/topics/gateway#gateway-intents). You may have tried to specify an intent that you [have not enabled or are not approved for](https://discord.com/developers/docs/topics/gateway#privileged-intents).
|
||||||
DisallowedIntents,
|
DisallowedIntents,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes
|
/// https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes
|
||||||
@ -1357,6 +1463,10 @@ pub const GatewayOpcodes = enum(u4) {
|
|||||||
Hello,
|
Hello,
|
||||||
/// Sent in response to receiving a heartbeat to acknowledge that it has been received.
|
/// Sent in response to receiving a heartbeat to acknowledge that it has been received.
|
||||||
HeartbeatACK,
|
HeartbeatACK,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const GatewayDispatchEventNames = union(enum) {
|
pub const GatewayDispatchEventNames = union(enum) {
|
||||||
@ -1458,6 +1568,10 @@ pub const InteractionResponseTypes = enum(u4) {
|
|||||||
/// @remarks
|
/// @remarks
|
||||||
/// Only available for apps with Activities enabled
|
/// Only available for apps with Activities enabled
|
||||||
LaunchActivity = 12,
|
LaunchActivity = 12,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const SortOrderTypes = enum {
|
pub const SortOrderTypes = enum {
|
||||||
@ -1465,6 +1579,10 @@ pub const SortOrderTypes = enum {
|
|||||||
LatestActivity,
|
LatestActivity,
|
||||||
/// Sort forum posts by creation time (from most recent to oldest)
|
/// Sort forum posts by creation time (from most recent to oldest)
|
||||||
CreationDate,
|
CreationDate,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ForumLayout = enum {
|
pub const ForumLayout = enum {
|
||||||
@ -1474,6 +1592,10 @@ pub const ForumLayout = enum {
|
|||||||
ListView,
|
ListView,
|
||||||
/// Display posts as a collection of tiles.
|
/// Display posts as a collection of tiles.
|
||||||
GalleryView,
|
GalleryView,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@intFromEnum(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// https://discord.com/developers/docs/reference#image-formatting
|
/// https://discord.com/developers/docs/reference#image-formatting
|
||||||
@ -1662,4 +1784,8 @@ pub const InteractionContextType = enum {
|
|||||||
BotDm,
|
BotDm,
|
||||||
/// Interaction can be used within Group DMs and DMs other than the app's bot user
|
/// Interaction can be used within Group DMs and DMs other than the app's bot user
|
||||||
PrivateChannel,
|
PrivateChannel,
|
||||||
|
|
||||||
|
pub fn jsonStringify(self: @This(), writer: anytype) !void {
|
||||||
|
try writer.print("{d}", .{@enumFromInt(self)});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const json = std.json;
|
const json = std.json;
|
||||||
|
|
||||||
|
const MAX_VALUE_LEN = 0x1000;
|
||||||
|
|
||||||
/// a hashmap for key value pairs
|
/// a hashmap for key value pairs
|
||||||
/// where every key is an int
|
/// where every key is an int
|
||||||
///
|
///
|
||||||
@ -49,7 +51,7 @@ pub fn AssociativeArray(comptime E: type, comptime V: type) type {
|
|||||||
|
|
||||||
const value = try std.json.innerParse(std.json.Value, allocator, src, .{
|
const value = try std.json.innerParse(std.json.Value, allocator, src, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100
|
.max_value_len = MAX_VALUE_LEN
|
||||||
});
|
});
|
||||||
|
|
||||||
var iterator = value.object.iterator();
|
var iterator = value.object.iterator();
|
||||||
@ -63,7 +65,7 @@ pub fn AssociativeArray(comptime E: type, comptime V: type) type {
|
|||||||
|
|
||||||
const val = try std.json.parseFromValueLeaky(V, allocator, v, .{
|
const val = try std.json.parseFromValueLeaky(V, allocator, v, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100,
|
.max_value_len = MAX_VALUE_LEN,
|
||||||
});
|
});
|
||||||
|
|
||||||
map.put(@enumFromInt(int), val);
|
map.put(@enumFromInt(int), val);
|
||||||
@ -98,7 +100,7 @@ pub fn DiscriminatedUnion(comptime U: type, comptime key: []const u8) type {
|
|||||||
|
|
||||||
const value = try std.json.innerParse(std.json.Value, allocator, src, .{
|
const value = try std.json.innerParse(std.json.Value, allocator, src, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100
|
.max_value_len = MAX_VALUE_LEN
|
||||||
});
|
});
|
||||||
|
|
||||||
const discriminator = value.object.get(key) orelse
|
const discriminator = value.object.get(key) orelse
|
||||||
@ -114,7 +116,7 @@ pub fn DiscriminatedUnion(comptime U: type, comptime key: []const u8) type {
|
|||||||
comptime std.debug.assert(@hasField(T, key));
|
comptime std.debug.assert(@hasField(T, key));
|
||||||
u = @unionInit(U, field.name, try std.json.innerParse(T, allocator, src, .{
|
u = @unionInit(U, field.name, try std.json.innerParse(T, allocator, src, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100,
|
.max_value_len = MAX_VALUE_LEN,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,7 +133,7 @@ pub fn Record(comptime T: type) type {
|
|||||||
pub fn jsonParse(allocator: std.mem.Allocator, src: anytype, _: json.ParseOptions) !@This() {
|
pub fn jsonParse(allocator: std.mem.Allocator, src: anytype, _: json.ParseOptions) !@This() {
|
||||||
const value = try std.json.innerParse(std.json.Value, allocator, src, .{
|
const value = try std.json.innerParse(std.json.Value, allocator, src, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100
|
.max_value_len = MAX_VALUE_LEN
|
||||||
});
|
});
|
||||||
|
|
||||||
errdefer value.object.deinit();
|
errdefer value.object.deinit();
|
||||||
@ -148,7 +150,7 @@ pub fn Record(comptime T: type) type {
|
|||||||
// errdefer v.deinit(allocator);
|
// errdefer v.deinit(allocator);
|
||||||
try map.put(allocator, k, try std.json.parseFromValue(T, allocator, v, .{
|
try map.put(allocator, k, try std.json.parseFromValue(T, allocator, v, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100,
|
.max_value_len = MAX_VALUE_LEN,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,12 +231,12 @@ pub fn parseRight(comptime L: type, comptime R: type, child_allocator: std.mem.A
|
|||||||
const allocator = owned.arena.allocator();
|
const allocator = owned.arena.allocator();
|
||||||
const value = try json.parseFromSliceLeaky(json.Value, allocator, data, .{
|
const value = try json.parseFromSliceLeaky(json.Value, allocator, data, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100,
|
.max_value_len = MAX_VALUE_LEN,
|
||||||
});
|
});
|
||||||
|
|
||||||
owned.value = .{ .right = try json.parseFromValueLeaky(R, allocator, value, .{
|
owned.value = .{ .right = try json.parseFromValueLeaky(R, allocator, value, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100,
|
.max_value_len = MAX_VALUE_LEN,
|
||||||
}) };
|
}) };
|
||||||
errdefer owned.arena.deinit();
|
errdefer owned.arena.deinit();
|
||||||
|
|
||||||
@ -252,12 +254,12 @@ pub fn parseLeft(comptime L: type, comptime R: type, child_allocator: std.mem.Al
|
|||||||
const allocator = owned.arena.allocator();
|
const allocator = owned.arena.allocator();
|
||||||
const value = try json.parseFromSliceLeaky(json.Value, allocator, data, .{
|
const value = try json.parseFromSliceLeaky(json.Value, allocator, data, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100,
|
.max_value_len = MAX_VALUE_LEN,
|
||||||
});
|
});
|
||||||
|
|
||||||
owned.value = .{ .left = try json.parseFromValueLeaky(L, allocator, value, .{
|
owned.value = .{ .left = try json.parseFromValueLeaky(L, allocator, value, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
.max_value_len = 0x100,
|
.max_value_len = MAX_VALUE_LEN,
|
||||||
}) };
|
}) };
|
||||||
errdefer owned.arena.deinit();
|
errdefer owned.arena.deinit();
|
||||||
|
|
||||||
|
@ -25,12 +25,43 @@ fn ready(_: *Shard, payload: Discord.Ready) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn message_create(_: *Shard, message: Discord.Message) !void {
|
fn message_create(_: *Shard, message: Discord.Message) !void {
|
||||||
if (message.content != null and std.ascii.eqlIgnoreCase(message.content.?, "!hi")) {
|
if (message.content != null) {
|
||||||
var result = try session.api.sendMessage(message.channel_id, .{ .content = "hi :)" });
|
if (std.ascii.eqlIgnoreCase(message.content.?, "!hi")) {
|
||||||
defer result.deinit();
|
var result = try session.api.sendMessage(message.channel_id, .{ .content = "hi :)" });
|
||||||
|
defer result.deinit();
|
||||||
|
|
||||||
const m = result.value.unwrap();
|
const m = result.value.unwrap();
|
||||||
std.debug.print("sent: {?s}\n", .{m.content});
|
std.debug.print("sent: {?s}\n", .{m.content});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.ascii.eqlIgnoreCase(message.content.?, "!ping")) {
|
||||||
|
var result = try session.api.sendMessage(message.channel_id, .{ .content = "pong" });
|
||||||
|
defer result.deinit();
|
||||||
|
const m = result.value.unwrap();
|
||||||
|
std.debug.print("sent: {?s}\n", .{m.content});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.ascii.eqlIgnoreCase(message.content.?, "!create-channel")) {
|
||||||
|
var result = try session.api.createChannel(message.guild_id.?, .{
|
||||||
|
.name = "test-channel",
|
||||||
|
.type = .GuildText,
|
||||||
|
.topic = null,
|
||||||
|
.bitrate = null,
|
||||||
|
.permission_overwrites = null,
|
||||||
|
.nsfw = false,
|
||||||
|
.default_reaction_emoji = null,
|
||||||
|
.available_tags = null,
|
||||||
|
});
|
||||||
|
defer result.deinit();
|
||||||
|
switch (result.value) {
|
||||||
|
.left => |err| {
|
||||||
|
std.debug.print("error creating channel: {any}\n", .{err});
|
||||||
|
},
|
||||||
|
.right => |channel| {
|
||||||
|
std.debug.print("created channel: {?s}\n", .{channel.name});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user