Current section

Files

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

src/discord_gleam@ws@packets@presence_update.erl

-module(discord_gleam@ws@packets@presence_update).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/discord_gleam/ws/packets/presence_update.gleam").
-export([string_to_data/1]).
-export_type([presence_update_packet/0]).
-type presence_update_packet() :: {presence_update_packet,
binary(),
integer(),
integer(),
discord_gleam@types@presence:presence()}.
-file("src/discord_gleam/ws/packets/presence_update.gleam", 9).
-spec string_to_data(binary()) -> {ok, presence_update_packet()} |
{error, gleam@json:decode_error()}.
string_to_data(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>>,
discord_gleam@types@presence:from_json_decoder(
),
fun(D) ->
gleam@dynamic@decode:success(
{presence_update_packet,
T,
S,
Op,
D}
)
end
)
end
)
end
)
end
)
end,
gleam@json:parse(Encoded, Decoder).