Current section

Files

Jump to
discord_gleam src discord_gleam@ws@packets@message_reaction_add.erl
Raw

src/discord_gleam@ws@packets@message_reaction_add.erl

-module(discord_gleam@ws@packets@message_reaction_add).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/discord_gleam/ws/packets/message_reaction_add.gleam").
-export([from_json_string/1]).
-export_type([message_reaction_add_packet_data/0, message_reaction_add_packet/0]).
-type message_reaction_add_packet_data() :: {message_reaction_add_packet_data,
discord_gleam@discord@snowflake:snowflake(discord_gleam@discord@snowflake:user()),
discord_gleam@discord@snowflake:snowflake(discord_gleam@discord@snowflake:channel()),
discord_gleam@discord@snowflake:snowflake(discord_gleam@discord@snowflake:message()),
gleam@option:option(discord_gleam@discord@snowflake:snowflake(discord_gleam@discord@snowflake:guild())),
gleam@option:option(discord_gleam@types@guild_member:guild_member()),
discord_gleam@types@emoji:emoji(),
gleam@option:option(discord_gleam@discord@snowflake:snowflake(discord_gleam@discord@snowflake:user())),
boolean(),
gleam@option:option(list(binary())),
gleam@option:option(integer())}.
-type message_reaction_add_packet() :: {message_reaction_add_packet,
binary(),
integer(),
integer(),
message_reaction_add_packet_data()}.
-file("src/discord_gleam/ws/packets/message_reaction_add.gleam", 32).
-spec from_json_string(binary()) -> {ok, message_reaction_add_packet()} |
{error, gleam@json:decode_error()}.
from_json_string(Encoded) ->
Decoder = begin
gleam@dynamic@decode:field(
<<"t"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(T) ->
gleam@dynamic@decode:field(
<<"s"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(S) ->
gleam@dynamic@decode:field(
<<"op"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Op) ->
gleam@dynamic@decode:field(
<<"d"/utf8>>,
begin
gleam@dynamic@decode:field(
<<"user_id"/utf8>>,
discord_gleam@discord@snowflake:decoder(
),
fun(User_id) ->
gleam@dynamic@decode:field(
<<"channel_id"/utf8>>,
discord_gleam@discord@snowflake:decoder(
),
fun(Channel_id) ->
gleam@dynamic@decode:field(
<<"message_id"/utf8>>,
discord_gleam@discord@snowflake:decoder(
),
fun(Message_id) ->
gleam@dynamic@decode:optional_field(
<<"guild_id"/utf8>>,
none,
gleam@dynamic@decode:optional(
discord_gleam@discord@snowflake:decoder(
)
),
fun(
Guild_id
) ->
gleam@dynamic@decode:optional_field(
<<"member"/utf8>>,
none,
gleam@dynamic@decode:optional(
discord_gleam@types@guild_member:json_decoder(
)
),
fun(
Member
) ->
gleam@dynamic@decode:field(
<<"emoji"/utf8>>,
discord_gleam@types@emoji:json_decoder(
),
fun(
Emoji
) ->
gleam@dynamic@decode:optional_field(
<<"message_author_id"/utf8>>,
none,
gleam@dynamic@decode:optional(
discord_gleam@discord@snowflake:decoder(
)
),
fun(
Message_author_id
) ->
gleam@dynamic@decode:field(
<<"burst"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_bool/1},
fun(
Burst
) ->
gleam@dynamic@decode:optional_field(
<<"burst_colors"/utf8>>,
none,
gleam@dynamic@decode:optional(
gleam@dynamic@decode:list(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
)
),
fun(
Burst_colors
) ->
gleam@dynamic@decode:optional_field(
<<"type"/utf8>>,
none,
gleam@dynamic@decode:optional(
{decoder,
fun gleam@dynamic@decode:decode_int/1}
),
fun(
Type_
) ->
gleam@dynamic@decode:success(
{message_reaction_add_packet_data,
User_id,
Channel_id,
Message_id,
Guild_id,
Member,
Emoji,
Message_author_id,
Burst,
Burst_colors,
Type_}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end,
fun(D) ->
gleam@dynamic@decode:success(
{message_reaction_add_packet,
T,
S,
Op,
D}
)
end
)
end
)
end
)
end
)
end,
gleam@json:parse(Encoded, Decoder).