Lingo.Format (Lingo v0.4.2)

Copy Markdown View Source

Markdown for mentions, emojis and timestamps (rendered in each reader's locale), escaping, and message links.

Summary

Functions

An emoji as message text: a Lingo.Type.Emoji, or any map with its :name and :id.

Escapes Markdown in text, so it shows as typed: emphasis, code, spoilers, and quotes, headings and lists at the start of a line.

Links a channel.

A clickable slash command. name may include a subcommand group and subcommand: "role add".

Mentions a role.

Mentions a user.

A link to a message. Pass nil as the guild id for DMs.

A timestamp, from a DateTime or Unix seconds. style is one of :short_time, :long_time, :short_date, :long_date, :short_datetime (the default), :long_datetime or :relative.

Functions

emoji(emoji)

An emoji as message text: a Lingo.Type.Emoji, or any map with its :name and :id.

escape_markdown(text)

Escapes Markdown in text, so it shows as typed: emphasis, code, spoilers, and quotes, headings and lists at the start of a line.

mention_channel(id)

Links a channel.

mention_command(name, command_id)

A clickable slash command. name may include a subcommand group and subcommand: "role add".

mention_role(id)

Mentions a role.

mention_user(id)

Mentions a user.

message_url(guild_id, channel_id, message_id)

A link to a message. Pass nil as the guild id for DMs.

timestamp(datetime, style \\ :short_datetime)

A timestamp, from a DateTime or Unix seconds. style is one of :short_time, :long_time, :short_date, :long_date, :short_datetime (the default), :long_datetime or :relative.

Lingo.Format.timestamp(DateTime.utc_now(), :relative)
#=> "<t:1767225600:R>"