Current section

Files

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

src/discord_gleam@ws@packets@channel_update.erl

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