Packages

A Gleam library for building Discord webhook payloads safely.

Current section

Files

Jump to
kitazith src kitazith@component@file.erl
Raw

src/kitazith@component@file.erl

-module(kitazith@component@file).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/kitazith/component/file.gleam").
-export([new/1, with_id/2, with_spoiler/2, to_json/1]).
-export_type([file/0]).
-type file() :: {file,
gleam@option:option(integer()),
kitazith@component@media:unfurled_media_item(),
gleam@option:option(boolean())}.
-file("src/kitazith/component/file.gleam", 18).
-spec new(kitazith@component@media:unfurled_media_item()) -> file().
new(File) ->
{file, none, File, none}.
-file("src/kitazith/component/file.gleam", 22).
-spec with_id(file(), integer()) -> file().
with_id(File, Id) ->
{file, {some, Id}, erlang:element(3, File), erlang:element(4, File)}.
-file("src/kitazith/component/file.gleam", 26).
-spec with_spoiler(file(), boolean()) -> file().
with_spoiler(File, Spoiler) ->
{file, erlang:element(2, File), erlang:element(3, File), {some, Spoiler}}.
-file("src/kitazith/component/file.gleam", 30).
-spec to_json(file()) -> gleam@json:json().
to_json(File) ->
kitazith@internal@json_helper:object_omit_none(
[{some, {<<"type"/utf8>>, gleam@json:int(13)}},
kitazith@internal@json_helper:optional(
<<"id"/utf8>>,
erlang:element(2, File),
fun gleam@json:int/1
),
{some,
{<<"file"/utf8>>,
kitazith@component@media:to_json(erlang:element(3, File))}},
kitazith@internal@json_helper:optional(
<<"spoiler"/utf8>>,
erlang:element(4, File),
fun gleam@json:bool/1
)]
).