Current section
Files
Jump to
Current section
Files
src/discord_gleam@ws@packets@identify.erl
-module(discord_gleam@ws@packets@identify).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/discord_gleam/ws/packets/identify.gleam").
-export([create_packet/2, create_resume_packet/4]).
-file("src/discord_gleam/ws/packets/identify.gleam", 5).
-spec create_packet(binary(), discord_gleam@discord@intents:intents()) -> binary().
create_packet(Token, Intents) ->
_pipe = gleam@json:object(
[{<<"op"/utf8>>, gleam@json:int(2)},
{<<"d"/utf8>>,
gleam@json:object(
[{<<"token"/utf8>>, gleam@json:string(Token)},
{<<"intents"/utf8>>,
gleam@json:int(
discord_gleam@discord@intents:intents_to_bitfield(
Intents
)
)},
{<<"properties"/utf8>>,
gleam@json:object(
[{<<"os"/utf8>>,
gleam@json:string(<<"gleam"/utf8>>)},
{<<"browser"/utf8>>,
gleam@json:string(
<<"discord_gleam"/utf8>>
)},
{<<"device"/utf8>>,
gleam@json:string(
<<"discord_gleam"/utf8>>
)}]
)}]
)}]
),
gleam@json:to_string(_pipe).
-file("src/discord_gleam/ws/packets/identify.gleam", 27).
-spec create_resume_packet(
binary(),
discord_gleam@discord@intents:intents(),
binary(),
binary()
) -> binary().
create_resume_packet(Token, Intents, Session_id, Sequence) ->
_pipe = gleam@json:object(
[{<<"op"/utf8>>, gleam@json:int(6)},
{<<"d"/utf8>>,
gleam@json:object(
[{<<"token"/utf8>>, gleam@json:string(Token)},
{<<"session_id"/utf8>>, gleam@json:string(Session_id)},
{<<"seq"/utf8>>,
gleam@json:int(
case gleam_stdlib:parse_int(Sequence) of
{ok, S} ->
S;
{error, _} ->
0
end
)},
{<<"intents"/utf8>>,
gleam@json:int(
discord_gleam@discord@intents:intents_to_bitfield(
Intents
)
)}]
)}]
),
gleam@json:to_string(_pipe).