chapterjs to write messages and work with ids and images.
How to send what they produce is in the Messages guide; everything a message can contain is in Message options.
Mentions
A structure put in a text becomes its mention:${user} is <@id>, ${channel} is <#id>, ${role} is <@&id>. When you only have an id, use these functions. They build text; Discord turns it into a mention when the message is shown.
userMention()
<@USER_ID>: mentions a user.
channelMention()
<#CHANNEL_ID>: links a channel.
roleMention()
<@&ROLE_ID>: mentions a role.
commandMention()
</NAME:COMMAND_ID>: a clickable slash command. The name includes the subcommand group and subcommand when there are some ("foo group bar").
emojiMention()
<:NAME:ID> or <a:NAME:ID>: a custom emoji.
GuildNavigation
Guild Navigation Types: links to a tab of the current server. Put the value in a message as it is.
Discord documentation
Dates
timestamp()
<t:TIMESTAMP> or <t:TIMESTAMP:STYLE>: a date shown to each reader in their own timezone and language. Timestamps are expressed in seconds.
A number is milliseconds since the Unix epoch, like Date.now(). Something that is not a date throws a TypeError:
TimestampStyle
Howtimestamp() is shown. Without a style, Discord uses LongDateShortTime.
Discord documentation
Ids
Snowflake
A Discord id: a 64-bit number serialized as a string.id is one, and every option that takes an id takes a Snowflake. It is text because the number is too big for a JavaScript number: never turn it into one.
isSnowflake()
snowflakeTimestamp()
(snowflake >> 22) + 1420070400000.
Structures already have createdAt; this is for an id alone.
snowflakeFromTimestamp()
before / after pagination start from a date.
RangeError:
Images
ImageOptions
What every method that ends withURL takes: user.avatarURL(), member.avatarURL(), guild.iconURL(), guild.bannerURL(), guild.splashURL(), role.iconURL(), emoji.url()…
The file format. By default: WebP, which Discord recommends since it works for still and animated images, whatever was uploaded.
false to get the first frame of an animated image. By default an animated image stays animated.- Asking for
'gif'on an image that is not animated gives a PNG instead. - An animated image stays animated only in WebP (the default) or GIF;
animated: falsegives its first frame. - A wrong value throws a
RangeErrorbefore any URL is built: