Packages

A Gleam library for building Discord webhook payloads safely.

Current section

Files

Jump to
kitazith src kitazith@message_formatting@mention.erl
Raw

src/kitazith@message_formatting@mention.erl

-module(kitazith@message_formatting@mention).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/kitazith/message_formatting/mention.gleam").
-export([user/1, role/1, channel/1, command/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" This module provides functions to create mentions for users, roles, channels, and commands in Discord.\n"
"\n"
" Each function takes a Snowflake (a unique identifier used by Discord) and returns a string formatted as a mention that can be used in messages.\n"
"\n"
" Learn more:\n"
" [API Reference - Documentation - Discord > Message Formatting > Formats](https://docs.discord.com/developers/reference#message-formatting-formats)\n"
).
-file("src/kitazith/message_formatting/mention.gleam", 12).
-spec user(kitazith@snowflake:snowflake()) -> binary().
user(Snowflake) ->
erlang:list_to_binary(
[<<"<@"/utf8>>, kitazith@snowflake:to_string(Snowflake), <<">"/utf8>>]
).
-file("src/kitazith/message_formatting/mention.gleam", 16).
-spec role(kitazith@snowflake:snowflake()) -> binary().
role(Snowflake) ->
erlang:list_to_binary(
[<<"<@&"/utf8>>, kitazith@snowflake:to_string(Snowflake), <<">"/utf8>>]
).
-file("src/kitazith/message_formatting/mention.gleam", 20).
-spec channel(kitazith@snowflake:snowflake()) -> binary().
channel(Snowflake) ->
erlang:list_to_binary(
[<<"<#"/utf8>>, kitazith@snowflake:to_string(Snowflake), <<">"/utf8>>]
).
-file("src/kitazith/message_formatting/mention.gleam", 24).
-spec command(binary(), kitazith@snowflake:snowflake()) -> binary().
command(Name, Snowflake) ->
erlang:list_to_binary(
[<<"</"/utf8>>,
Name,
<<":"/utf8>>,
kitazith@snowflake:to_string(Snowflake),
<<">"/utf8>>]
).