Current section

Files

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

src/discord_gleam@ws@packets@message_reaction_remove.erl

-module(discord_gleam@ws@packets@message_reaction_remove).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/discord_gleam/ws/packets/message_reaction_remove.gleam").
-export([from_json_string/1]).
-export_type([message_reaction_remove_packet_data/0, message_reaction_remove_packet/0]).
-type message_reaction_remove_packet_data() :: {message_reaction_remove_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())),
discord_gleam@types@emoji:emoji(),
boolean(),
gleam@option:option(integer())}.
-type message_reaction_remove_packet() :: {message_reaction_remove_packet,
binary(),
integer(),
integer(),
message_reaction_remove_packet_data()}.
-file("src/discord_gleam/ws/packets/message_reaction_remove.gleam", 28).
-spec from_json_string(binary()) -> {ok, message_reaction_remove_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:field(
<<"emoji"/utf8>>,
discord_gleam@types@emoji:json_decoder(
),
fun(
Emoji
) ->
gleam@dynamic@decode:field(
<<"burst"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_bool/1},
fun(
Burst
) ->
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_remove_packet_data,
User_id,
Channel_id,
Message_id,
Guild_id,
Emoji,
Burst,
Type_}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end,
fun(D) ->
gleam@dynamic@decode:success(
{message_reaction_remove_packet,
T,
S,
Op,
D}
)
end
)
end
)
end
)
end
)
end,
gleam@json:parse(Encoded, Decoder).