-module(discord_gleam@ws@packets@message). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/discord_gleam/ws/packets/message.gleam"). -export([data_json_decoder/0, json_decoder/0, from_json_string/1]). -export_type([message_packet_data/0, message_packet/0]). -type message_packet_data() :: {message_packet_data, 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@discord@snowflake:snowflake(discord_gleam@discord@snowflake:channel()), discord_gleam@types@user:user(), binary(), binary(), gleam@option:option(binary()), boolean(), boolean(), list(discord_gleam@types@user:user()), list(discord_gleam@discord@snowflake:snowflake(discord_gleam@discord@snowflake:role())), list(discord_gleam@types@embed:embed()), gleam@option:option(binary()), boolean(), gleam@option:option(discord_gleam@discord@snowflake:snowflake(discord_gleam@discord@snowflake:webhook())), integer(), gleam@option:option(discord_gleam@discord@snowflake:snowflake(discord_gleam@discord@snowflake:application())), gleam@option:option(integer()), gleam@option:option(message_packet_data()), gleam@option:option(discord_gleam@types@channel:channel()), gleam@option:option(integer())}. -type message_packet() :: {message_packet, binary(), integer(), integer(), message_packet_data()}. -file("src/discord_gleam/ws/packets/message.gleam", 65). -spec data_json_decoder() -> gleam@dynamic@decode:decoder(message_packet_data()). data_json_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, discord_gleam@discord@snowflake:decoder(), fun(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( <<"channel_id"/utf8>>, discord_gleam@discord@snowflake:decoder(), fun(Channel_id) -> gleam@dynamic@decode:field( <<"author"/utf8>>, discord_gleam@types@user:json_decoder(), fun(Author) -> gleam@dynamic@decode:field( <<"content"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Content) -> gleam@dynamic@decode:field( <<"timestamp"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Timestamp) -> gleam@dynamic@decode:optional_field( <<"edited_timestamp"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Edited_timestamp) -> gleam@dynamic@decode:field( <<"tts"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_bool/1}, fun(Tts) -> gleam@dynamic@decode:field( <<"mention_everyone"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_bool/1}, fun( Mention_everyone ) -> gleam@dynamic@decode:field( <<"mentions"/utf8>>, gleam@dynamic@decode:list( discord_gleam@types@user:json_decoder( ) ), fun( Mentions ) -> gleam@dynamic@decode:field( <<"mention_roles"/utf8>>, gleam@dynamic@decode:list( discord_gleam@discord@snowflake:decoder( ) ), fun( Mention_roles ) -> gleam@dynamic@decode:field( <<"embeds"/utf8>>, gleam@dynamic@decode:list( discord_gleam@types@embed:json_decoder( ) ), fun( Embeds ) -> gleam@dynamic@decode:optional_field( <<"nonce"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Nonce ) -> gleam@dynamic@decode:field( <<"pinned"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_bool/1}, fun( Pinned ) -> gleam@dynamic@decode:optional_field( <<"webhook_id"/utf8>>, none, gleam@dynamic@decode:optional( discord_gleam@discord@snowflake:decoder( ) ), fun( Webhook_id ) -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun( Type_ ) -> gleam@dynamic@decode:optional_field( <<"application_id"/utf8>>, none, gleam@dynamic@decode:optional( discord_gleam@discord@snowflake:decoder( ) ), fun( Application_id ) -> gleam@dynamic@decode:optional_field( <<"flags"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun( Flags ) -> gleam@dynamic@decode:optional_field( <<"referenced_message"/utf8>>, none, gleam@dynamic@decode:optional( data_json_decoder( ) ), fun( Referenced_message ) -> gleam@dynamic@decode:optional_field( <<"thread"/utf8>>, none, gleam@dynamic@decode:optional( discord_gleam@types@channel:json_decoder( ) ), fun( Thread ) -> gleam@dynamic@decode:optional_field( <<"position"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun( Position ) -> gleam@dynamic@decode:success( {message_packet_data, Id, Guild_id, Channel_id, Author, Content, Timestamp, Edited_timestamp, Tts, Mention_everyone, Mentions, Mention_roles, Embeds, Nonce, Pinned, Webhook_id, Type_, Application_id, Flags, Referenced_message, Thread, Position} ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ). -file("src/discord_gleam/ws/packets/message.gleam", 208). -spec json_decoder() -> gleam@dynamic@decode:decoder(message_packet()). json_decoder() -> 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>>, data_json_decoder(), fun(D) -> gleam@dynamic@decode:success( {message_packet, T, S, Op, D} ) end ) end ) end ) end ). -file("src/discord_gleam/ws/packets/message.gleam", 59). -spec from_json_string(binary()) -> {ok, message_packet()} | {error, gleam@json:decode_error()}. from_json_string(Encoded) -> gleam@json:parse(Encoded, json_decoder()).