Discord mention and timestamp formatting helpers.
Generates the special syntax Discord uses to render mentions, channels, roles, emojis, and timestamps in messages.
Unlike EDA.User.mention/1 or EDA.Role.mention/1 which work on structs,
these functions accept raw IDs directly — useful when you only have an ID
string without fetching the full entity.
Examples
import EDA.Mention
user("123456") #=> "<@123456>"
channel("789") #=> "<#789>"
role("456") #=> "<@&456>"
timestamp(1_700_000_000, :R) #=> "<t:1700000000:R>"
Summary
Functions
Formats a channel mention.
Formats a custom emoji.
Formats a role mention.
Formats a Unix timestamp for Discord rendering.
Formats a user mention.
Functions
Formats a channel mention.
Examples
EDA.Mention.channel("123456789") #=> "<#123456789>"
Formats a custom emoji.
Examples
EDA.Mention.emoji("wave", "123456") #=> "<:wave:123456>"
EDA.Mention.emoji("wave", "123456", true) #=> "<a:wave:123456>"
Formats a role mention.
Examples
EDA.Mention.role("123456789") #=> "<@&123456789>"
Formats a Unix timestamp for Discord rendering.
Discord will render the timestamp in the user's local timezone.
Styles
| Style | Example output | Atom |
|---|---|---|
| Short time | 4:20 PM | :t |
| Long time | 4:20:30 PM | :T |
| Short date | 11/14/2023 | :d |
| Long date | November 14, 2023 | :D |
| Short date/time | November 14, 2023 4:20 PM | :f |
| Long date/time | Tuesday, November 14, 2023 4:20 PM | :F |
| Relative | 2 hours ago | :R |
Examples
EDA.Mention.timestamp(1_700_000_000) #=> "<t:1700000000>"
EDA.Mention.timestamp(1_700_000_000, :R) #=> "<t:1700000000:R>"
EDA.Mention.timestamp(1_700_000_000, :f) #=> "<t:1700000000:f>"
Formats a user mention.
Examples
EDA.Mention.user("123456789") #=> "<@123456789>"