-module(kitazith@attachment). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/kitazith/attachment.gleam"). -export([new/2, with_description/2, to_embed_url/1, to_json/1]). -export_type([attachment/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type attachment() :: {attachment, integer(), binary(), gleam@option:option(binary())}. -file("src/kitazith/attachment.gleam", 15). -spec new(integer(), binary()) -> attachment(). new(Id, Filename) -> {attachment, Id, Filename, none}. -file("src/kitazith/attachment.gleam", 19). -spec with_description(attachment(), binary()) -> attachment(). with_description(Attachment, Description) -> {attachment, erlang:element(2, Attachment), erlang:element(3, Attachment), {some, Description}}. -file("src/kitazith/attachment.gleam", 30). ?DOC( " Format an attachment for use in embed image or thumbnail URLs.\n" "\n" " Discord accepts `attachment://filename` to reference uploaded attachments\n" " from embeds in the same message payload.\n" ). -spec to_embed_url(attachment()) -> binary(). to_embed_url(Attachment) -> <<"attachment://"/utf8, (erlang:element(3, Attachment))/binary>>. -file("src/kitazith/attachment.gleam", 34). -spec to_json(attachment()) -> gleam@json:json(). to_json(A) -> kitazith@internal@json_helper:object_omit_none( [{some, {<<"id"/utf8>>, gleam@json:int(erlang:element(2, A))}}, {some, {<<"filename"/utf8>>, gleam@json:string(erlang:element(3, A))}}, kitazith@internal@json_helper:optional( <<"description"/utf8>>, erlang:element(4, A), fun gleam@json:string/1 )] ).