34 symbols from @neontechspace/fluxerly
Variables#
AssetFormats #
Choose the image format for an asset URL
WebP is the default. Sticker URLs do not accept this choice
const AssetFormats: Readonly<{ … }>TimestampStyles #
Choose how Fluxer displays a timestamp in a message
The viewer's locale and timezone control its rendered text
const TimestampStyles: Readonly<{ … }>Long#Date -
Written-out date
"D" Long#Date Time -
Written-out date and time
"F" Long#Time -
Time including seconds
"T" Relative#Time -
Time relative to the viewer's current time, such as "a few minutes ago"
"R" Short#Date -
Compact date
"d" Short#Date Medium Time -
Compact date and time including seconds
"S" Short#Date Short Time -
Compact date and short time
"s" Short#Date Time -
Date and time, the default used by
format.timestamp "f" Short#Time -
Time without seconds
"t"
assets#
Build hosted Fluxer URLs for avatars, banners, community images, emoji and stickers
Calls return the URL, null or undefined directly and throw Asset for invalid input. They do not download the image or need a client. Use client for helpers tied to a self-hosted instance instead. Member avatar and banner helpers read only guild, user and the chosen image hash. The display helper also reads profile to choose the fallback image
const assets: AssetHelpersbuilders#
Start optional chainable builders for embed and message objects
Both package entry points return builders immediately, not lazy Effects
const builders: Readonly<{ … }>embed#-
Return a new empty
EmbedBuilder Call build to get a plain embed object, no message is sent
() => EmbedBuilder message#-
Return a new empty
MessageBuilder Select content, an embed, an attachment or a sticker before building
() => MessageBuilder<false>
colors#
Convert supported RGB numbers, six-digit hex strings and RGB tuples into colors
Invalid input throws Helper rather than being converted automatically. For colors received from users, try returns a Result instead of throwing. No client or network request is needed
const colors: ColorHelpersdisplay#
const display: DisplayHelpersformat#
Create Fluxer markup for mentions, timestamps, custom emoji and Markdown escaping
Use these helpers when building message content, without creating a client or making a request. Helpers return plain values and throw Helper for invalid input, which indicates a programming mistake. For text received from users, try, try and try return a Result instead of throwing. Check is before reading value, or is before reading error. A mention in the text does not enable notifications, which are controlled by allowed when sending
const format: FormatHelperslinks#
Build links to Fluxer channels, direct messages, messages and bot installation pages
These helpers use hosted Fluxer URLs. Each helper returns the URL directly, and invalid route inputs throw Helper. Building a link does not check access or install the bot
const links: LinkHelperssnowflakes#
Read and convert Fluxer's IDs, called snowflakes, without losing integer precision
Keep IDs as decimal strings rather than JavaScript numbers. Conversions return plain values and throw Helper for an invalid ID or Date. For IDs received from users, try returns a Result instead of throwing
const snowflakes: SnowflakeHelperstext#
Split a string into frozen pieces without dropping its text, or truncate it to a length with a marker
Each lone surrogate becomes U+FFFD (�) first. The max option of split and truncate counts UTF-16 code units, as JavaScript string does. Cuts fall between visible characters, so a piece or truncated string can be shorter than max. Only split cuts inside a single character, and only one longer than max. Truncate returns the suffix alone when its first character does not fit before the suffix. The pieces or the truncated string are returned directly, and invalid text or options throw Helper. These helpers neither send the result nor repair Markdown cut by it
const text: TextHelpersClasses#
EmbedBuilder - Assemble an embed by chaining methods, then pass the builder or
build()'s plain object in a message operation's embeds MessageBuilder - Assemble a message by chaining methods, then send the plain object returned by
build()
Interfaces#
AssetUrlOptions #
Choose the format, size and animation to request in an asset URL
Unknown keys or invalid values throw Asset, even when the target has no image
interface AssetUrlOptionsanimatedoptional#-
Request animation or a still image
When omitted, animated asset hashes or emoji metadata select animation. Requesting animation with Png or Jpeg throws
Asset, choose animated false to request a still image insteadUrl Error boolean formatoptional#-
Output encoding
Webpis used when omittedAssetFormat sizeoptional#-
Requested image size in pixels, an integer from 0 through 4_294_967_295
Omit it to leave size selection to Fluxer. The helper sends it unchanged, Fluxer selects a supported size for that asset
number
CustomEmojiMarkup #
Custom-emoji fields used by Fluxer's explicit <:name:id> or <a:name:id> markup
interface CustomEmojiMarkupEmbedFieldOptions #
Display settings for one field added with Embed
interface EmbedFieldOptionsinlineoptional#-
Request side-by-side display with neighboring inline fields
Omit or use false for a full-width field
boolean
InstallationLinkOptions #
Optional raw permission bitfield requested by a hosted bot-installation page
interface InstallationLinkOptionspermissionsoptional#-
Unsigned 64-bit Fluxer permission bitfield
Omit it to leave the provider's requested permissions unspecified
bigint
StickerAssetUrlOptions #
Choose sticker size and animation
There is no format option because Fluxer chooses the sticker encoding. Unknown keys or invalid values throw Asset
interface StickerAssetUrlOptionsanimatedoptional#-
Override the sticker's animated metadata
Animated stickers return their GIF source, other stickers return WebP
boolean sizeoptional#-
Requested size in pixels, an integer from 0 through 4_294_967_295
Omit to leave size selection to Fluxer, the helper does not resize it locally
number
TextSplitOptions #
Choose the largest piece text may return
Supply a limit explicitly. This helper does not discover a server's message limit
interface TextSplitOptionsmax#Length -
Maximum
stringof each piece, a positive safe integer with no default.length Most emoji count as two or more units, and a piece can be shorter when a visible character would otherwise be cut
number
TextTruncateOptions #
Choose where text cuts and what it appends
Supply the limit explicitly. This helper does not discover a server's message limit
interface TextTruncateOptionsmax#Length -
Maximum
stringof the result including the suffix, a positive safe integer with no default.length Most emoji count as two or more units, and the result can be shorter when a visible character would otherwise be cut, down to the suffix alone
number suffixoptional#-
Text appended after a cut, a well-formed string of at most
maxunitsLength Defaults to "…" (U+2026). Pass "" for a hard cut
string
TimestampMarkup #
One parsed timestamp markup value
The date field has whole-second precision because Fluxer markup has no milliseconds
interface TimestampMarkupdate#-
UTC instant represented by the markup
Date style#-
Explicit style, or Fluxer's default short-date-time style when omitted in the markup
TimestampStyle
Type Aliases#
AssetFormat #
One image encoding the hosted Fluxer media proxy can produce
type AssetFormat = typeof AssetFormats[keyof typeof AssetFormats]type AssetFormat =
typeof AssetFormats[
keyof typeof AssetFormats
]AssetHelpers #
Methods of the assets helper, which builds image URLs for avatars, banners, community images, emoji and stickers
Each method returns its URL, null or undefined directly and throws Asset for an invalid target, ID, hash or option
type AssetHelpers = Readonly<{ … }>avatar#
Build the user's custom-avatar URL, or null when the avatar field is null
Uses only the supplied id and avatar fields, and no profile is fetched. An omitted avatar is invalid and throws Asset
avatar(
user: Pick<User, "id" | "avatar">,
options?: AssetUrlOptions
): string | nullavatar(
user:
Pick<User, "id" | "avatar">,
options?: AssetUrlOptions
): string | nullParameters
user-
Pick<User, "id" | "avatar"> optionsoptional-
AssetUrlOptions
- Returns
string | null
defaultAvatar #
Build Fluxer's static default-avatar URL from a canonical user ID
Static defaults have no media transform query and do not depend on user-profile availability
defaultAvatar(userId: string): stringParameters
userId -
string
- Returns
string
displayAvatar #
Build a URL suitable for displaying a user avatar, using the custom avatar or a static default when avatar is null
Requires known user id and avatar fields. It never produces null, and invalid targets or options throw Asset
displayAvatar(
user: Pick<User, "id" | "avatar">,
options?: AssetUrlOptions
): stringdisplayAvatar(
user:
Pick<User, "id" | "avatar">,
options?: AssetUrlOptions
): stringParameters
user-
Pick<User, "id" | "avatar"> optionsoptional-
AssetUrlOptions
- Returns
string
displayMemberAvatar #
Choose an avatar to display for a user in a community
The user ID must match member. Normally chooses the member avatar, then the account avatar, then a static default, while AvatarUnset selects the static default directly. Produces undefined if profile is omitted or avatar is omitted without AvatarUnset. Reads guild, user, avatar and profile from the member, not banner. Invalid targets or options throw Asset
displayMemberAvatar(
user: Pick<User, "id" | "avatar">,
member: Pick<
GuildMember,
"guildId" | "userId" | "avatar" | "profileFlags"
>,
options?: AssetUrlOptions
): string | undefineddisplayMemberAvatar(
user:
Pick<User, "id" | "avatar">,
member: Pick<
GuildMember,
| "guildId" | "userId"
| "avatar" | "profileFlags"
>,
options?: AssetUrlOptions
): string | undefinedParameters
user-
Pick<User, "id" | "avatar"> member-
Pick<GuildMember, "guildId" | "userId" | "avatar" | "profileFlags">Pick< GuildMember, | "guildId" | "userId" | "avatar" | "profileFlags" > optionsoptional-
AssetUrlOptions
- Returns
string | undefined
emoji#
Build a custom-emoji image URL from only its ID and animated metadata, without looking up the emoji
Animated emoji request animation by default. Choose Webp, Gif or Apng to preserve it, or animated false for a still image
emoji(
emoji: Pick<GuildEmoji, "id" | "animated">,
options?: AssetUrlOptions
): stringemoji(
emoji: Pick<
GuildEmoji, "id" | "animated"
>,
options?: AssetUrlOptions
): stringParameters
emoji-
Pick<GuildEmoji, "id" | "animated"> optionsoptional-
AssetUrlOptions
- Returns
string
guildBanner #
Build a community banner URL from the community's id and banner
An omitted banner hash produces undefined, and an explicitly absent banner produces null
guildBanner(
guild: Pick<Guild, "id" | "banner">,
options?: AssetUrlOptions
): string | null | undefinedguildBanner(
guild:
Pick<Guild, "id" | "banner">,
options?: AssetUrlOptions
): string | null | undefinedParameters
guild-
Pick<Guild, "id" | "banner"> optionsoptional-
AssetUrlOptions
- Returns
string | null | undefined
guildEmbedSplash #
Build the background image URL for an embedded community invite, using id and embed
An omitted embed hash produces undefined, and an explicitly absent one produces null
guildEmbedSplash(
guild: Pick<Guild, "id" | "embedSplash">,
options?: AssetUrlOptions
): string | null | undefinedguildEmbedSplash(
guild: Pick<
Guild, "id" | "embedSplash"
>,
options?: AssetUrlOptions
): string | null | undefinedParameters
guild-
Pick<Guild, "id" | "embedSplash"> optionsoptional-
AssetUrlOptions
- Returns
string | null | undefined
guildIcon #
Build a community icon URL from the community's id and icon
An omitted icon hash produces undefined, and an explicitly absent icon produces null
guildIcon(
guild: Pick<Guild, "id" | "icon">,
options?: AssetUrlOptions
): string | null | undefinedguildIcon(
guild:
Pick<Guild, "id" | "icon">,
options?: AssetUrlOptions
): string | null | undefinedParameters
guild-
Pick<Guild, "id" | "icon"> optionsoptional-
AssetUrlOptions
- Returns
string | null | undefined
guildSplash #
Build the community's invite-background image URL from id and splash
An omitted splash hash produces undefined, and an explicitly absent splash produces null
guildSplash(
guild: Pick<Guild, "id" | "splash">,
options?: AssetUrlOptions
): string | null | undefinedguildSplash(
guild:
Pick<Guild, "id" | "splash">,
options?: AssetUrlOptions
): string | null | undefinedParameters
guild-
Pick<Guild, "id" | "splash"> optionsoptional-
AssetUrlOptions
- Returns
string | null | undefined
memberAvatar #
Build the member's community avatar URL using only guild, user and avatar
Produces undefined for an omitted avatar hash, or null for an explicitly absent avatar. It does not choose a fallback, which display provides
memberAvatar(
member: Pick<GuildMember, "guildId" | "userId" | "avatar">,
options?: AssetUrlOptions
): string | null | undefinedmemberAvatar(
member: Pick<
GuildMember,
"guildId" | "userId" | "avatar"
>,
options?: AssetUrlOptions
): string | null | undefinedParameters
member-
Pick<GuildMember, "guildId" | "userId" | "avatar">Pick< GuildMember, "guildId" | "userId" | "avatar" > optionsoptional-
AssetUrlOptions
- Returns
string | null | undefined
memberBanner #
Build the member's community banner URL using only guild, user and banner
Produces undefined for an omitted banner hash, or null for an explicitly absent banner. It does not substitute the account banner
memberBanner(
member: Pick<GuildMember, "guildId" | "userId" | "banner">,
options?: AssetUrlOptions
): string | null | undefinedmemberBanner(
member: Pick<
GuildMember,
"guildId" | "userId" | "banner"
>,
options?: AssetUrlOptions
): string | null | undefinedParameters
member-
Pick<GuildMember, "guildId" | "userId" | "banner">Pick< GuildMember, "guildId" | "userId" | "banner" > optionsoptional-
AssetUrlOptions
- Returns
string | null | undefined
roleIcon #
Build a role icon URL from the role's id and icon
Role icons are never animated. An omitted icon hash produces undefined, and an explicitly absent icon produces null. A role that shows an emoji has no image icon, so read its unicode
roleIcon(
role: Pick<GuildRole, "id" | "icon">,
options?: AssetUrlOptions
): string | null | undefinedroleIcon(
role:
Pick<GuildRole, "id" | "icon">,
options?: AssetUrlOptions
): string | null | undefinedParameters
role-
Pick<GuildRole, "id" | "icon"> optionsoptional-
AssetUrlOptions
- Returns
string | null | undefined
sticker#
Build a custom-sticker URL from only its ID and animated metadata
Sticker format is intentionally absent, because Fluxer returns WebP except an animated sticker's GIF source
sticker(
sticker: Pick<GuildSticker, "id" | "animated">,
options?: StickerAssetUrlOptions
): stringsticker(
sticker: Pick<
GuildSticker, "id" | "animated"
>,
options?: StickerAssetUrlOptions
): stringParameters
sticker-
Pick<GuildSticker, "id" | "animated"> optionsoptional-
StickerAssetUrlOptions
- Returns
string
userBanner #
Build an account-banner URL from a users result, using only user and profile
A null banner stays null, even when a limited profile withheld the banner, so null does not prove that the account has no banner. Uses Asset' WebP default and transform validation, without fetching, selecting a community banner or verifying existence or access
userBanner(
profile: Readonly<
{
profile: Pick<UserProfileFields, "banner">
user: Pick<User, "id">
}
>,
options?: AssetUrlOptions
): string | nulluserBanner(
profile: Readonly<
{
profile: Pick<
UserProfileFields, "banner"
>
user: Pick<User, "id">
}
>,
options?: AssetUrlOptions
): string | nullParameters
profile-
Readonly< { profile: Pick<UserProfileFields, "banner"> user: Pick<User, "id"> } >Readonly< { profile: Pick< UserProfileFields, "banner" > user: Pick<User, "id"> } > optionsoptional-
AssetUrlOptions
- Returns
string | null
ChannelLinkTarget #
The channel information needed to make a web link: Its id and, for a community channel, its guild
Supply a direct-message channel without guild. Passing guild is not the direct-message form
type ChannelLinkTarget =
| Pick<GuildChannel, "id" | "guildId">
| Pick<DirectMessageChannel, "id">type ChannelLinkTarget =
| Pick<
GuildChannel,
"id" | "guildId"
>
| Pick<
DirectMessageChannel, "id"
>ColorHelpers #
Methods of the colors helper, which converts RGB numbers, hex strings and tuples
Most methods return plain values and throw Helper for invalid input. The try method accepts untrusted input and returns a Result instead of throwing
type ColorHelpers = Readonly<{ … }>parse#
Convert a six-digit hexadecimal string, an RGB array of three integer channels from 0 through 255, or a color number to the integer used by embeds and roles
The leading # is optional. CSS names, three-digit shorthand, alpha channels and surrounding whitespace are rejected. Values are never rounded or clamped, and invalid input throws Helper. For colors received from users, use try, which reports the same Helper without throwing
parse(value: ColorInput): numberParameters
value-
ColorInput
- Returns
number
toHex #
Turn a color integer into a lowercase six-digit string such as "#000001", including leading zeroes
Accepts only integers from 0 through 0xffffff, not the strings or arrays accepted by parse. Throws Helper for invalid numbers
toHex(value: number): stringParameters
value-
number
- Returns
string
toRgb #
Split a color integer into a new frozen [red, green, blue] array, each from 0 through 255
Accepts only integers from 0 through 0xffffff. Throws Helper for invalid numbers
toRgb(value: number): RgbColorParameters
value-
number
- Returns
RgbColor
tryParse #
Convert a color with the same rules as parse, but report invalid input without throwing
The default API returns a Result holding the color integer or Helper. The native API returns an Effect that reads the input when run and fails with Helper. Use it for colors received from users or other untrusted sources
tryParse(value: ColorInput): Result<number, HelperError>tryParse(
value: ColorInput
): Result<number, HelperError>Parameters
value-
ColorInput
- Returns
Result<number, HelperError>- Fails with
ColorInput #
A color accepted by colors: A number from 0 through 0xffffff, six hexadecimal digits such as "#ff8800", or [255, 136, 0]
type ColorInput = number | string | RgbColortype ColorInput =
number | string | RgbColorDisplayHelpers #
Methods of the display helper, which chooses a display name from supplied user or member data
type DisplayHelpers = Readonly<{ … }>type DisplayHelpers =
Readonly<{ … }>name#
Return the member's nickname, otherwise the user's display, otherwise username
Only null or undefined trigger a fallback. Supply a member for the same user, this helper does not check identity or fetch data
name(
user:
& Pick<User, "username">
& { readonly displayName?: string | null },
member?: Pick<GuildMember, "nickname">
): stringname(
user:
& Pick<User, "username">
& {
readonly displayName?:
| string | null
},
member?:
Pick<GuildMember, "nickname">
): stringParameters
user-
Pick<User, "username"> & { readonly displayName?: string | null }& Pick<User, "username"> & { readonly displayName?: | string | null } memberoptional-
Pick<GuildMember, "nickname">
- Returns
string
FormatHelpers #
Methods of the format helper, which creates and reads mention, timestamp and custom-emoji markup and escapes Markdown
Most methods return plain values and throw Helper for invalid input. The try-prefixed parsers accept untrusted text and return a Result instead of throwing
type FormatHelpers = Readonly<{ … }>type FormatHelpers =
Readonly<{ … }>channelMention #
Create <#id> text linking to a channel, such as <#123>, and return it directly
Throws Helper for an invalid decimal-string ID, and no channel lookup occurs
channelMention(id: string): stringParameters
id-
string
- Returns
string
customEmoji #
Create <:name:id> text, or <a:name:id> when animated is true
A Guild can be passed directly. Throws Helper for invalid names, IDs or animation values. This does not upload or look up an emoji
customEmoji(input: CustomEmojiMarkup): stringcustomEmoji(
input: CustomEmojiMarkup
): stringParameters
input-
CustomEmojiMarkup
- Returns
string
escapeMarkdown #
Add backslashes so text is treated literally by Fluxer's markup parser, for example escaping **bold**
Returns the escaped string immediately and never throws for string input. It does not change a message's allowed or enable notifications
escapeMarkdown(value: string): stringParameters
value-
string
- Returns
string
parseCustomEmoji #
Read exactly one <:name:id> or <a:name:id> string into frozen name, ID and animated fields
Throws Helper for malformed markup. This does not resolve shortcodes such as :smile: or parse Unicode emoji. For text received from users, use try, which reports the same Helper without throwing
parseCustomEmoji(value: string): CustomEmojiMarkupparseCustomEmoji(
value: string
): CustomEmojiMarkupParameters
value-
string
- Returns
CustomEmojiMarkup
parseMention #
Read a string containing exactly one user, role or channel mention into a frozen { kind, id } object
Both <@id> and <@!id> produce kind "user". Throws Helper for surrounding text, malformed markup or an invalid decimal ID. For text received from users, use try, which reports the same Helper without throwing
parseMention(value: string): MentionParameters
value-
string
- Returns
Mention
parseTimestamp #
Read exactly one <t:seconds:style> or <t:seconds> string into a frozen object with a new Date and style
A missing style becomes ShortDateTime. The Date has whole-second precision. Throws Helper for malformed markup, nonpositive seconds or dates outside JavaScript's range. For text received from users, use try, which reports the same Helper without throwing
parseTimestamp(value: string): TimestampMarkupparseTimestamp(
value: string
): TimestampMarkupParameters
value-
string
- Returns
TimestampMarkup
roleMention #
Create <@&id> text for a decimal role ID, such as <@&123>, and return it directly
Throws Helper for an invalid ID. Role members are not notified merely because this text appears in a message, and allowed must be set separately
roleMention(id: string): stringParameters
id-
string
- Returns
string
timestamp#
Create <t:seconds:style> message text from a Date, which Fluxer displays in the reader's local time
The style defaults to ShortDateTime, and milliseconds are dropped. The whole Unix second must be from 1 through 8_640_000_000_000. Throws Helper for an invalid Date, a time outside that range or an unsupported style. The input Date is not changed
timestamp(value: Date, style?: TimestampStyle): stringtimestamp(
value: Date,
style?: TimestampStyle
): stringParameters
value-
Date styleoptional-
TimestampStyle
- Returns
string
tryParseCustomEmoji #
Read custom-emoji markup with the same rules as parse, but report invalid text without throwing
The default API returns a Result holding the frozen name, ID and animated fields or Helper. The native API returns an Effect that reads the text when run and fails with Helper. Use it for text received from users or other untrusted sources
tryParseCustomEmoji(value: string): Result<
CustomEmojiMarkup, HelperError
>tryParseCustomEmoji(
value: string
): Result<
CustomEmojiMarkup, HelperError
>Parameters
value-
string
- Returns
Result<CustomEmojiMarkup, HelperError>- Fails with
tryParseMention #
Read a mention with the same rules as parse, but report invalid text without throwing
The default API returns a Result holding the frozen { kind, id } object or Helper. The native API returns an Effect that reads the text when run and fails with Helper. Use it for text received from users or other untrusted sources
tryParseMention(value: string): Result<Mention, HelperError>tryParseMention(value: string): Result<
Mention, HelperError
>Parameters
value-
string
- Returns
Result<Mention, HelperError>- Fails with
tryParseTimestamp #
Read timestamp markup with the same rules as parse, but report invalid text without throwing
The default API returns a Result holding the frozen date and style or Helper. The native API returns an Effect that reads the text when run and fails with Helper. Use it for text received from users or other untrusted sources
tryParseTimestamp(value: string): Result<
TimestampMarkup, HelperError
>tryParseTimestamp(
value: string
): Result<
TimestampMarkup, HelperError
>Parameters
value-
string
- Returns
Result<TimestampMarkup, HelperError>- Fails with
userMention #
Create <@id> text for a decimal user ID, such as <@123>, and return it directly
Throws Helper when the ID is not a valid decimal-string snowflake. This does not look up the user, and allowed must be set separately to request a notification
userMention(id: string): stringParameters
id-
string
- Returns
string
LinkHelpers #
Methods of the links helper, which builds Fluxer channel, message and installation URLs
Each method returns the URL directly and throws Helper for invalid input
type LinkHelpers = Readonly<{ … }>channel#
Build a hosted community-channel or direct-message URL from { id, guild for a community channel or { id } for a private conversation
Direct inputs use Fluxer's /channels/@me/:channel route. Throws Helper for invalid decimal IDs. A URL does not prove the channel exists or the reader can open it
channel(target: ChannelLinkTarget): stringchannel(
target: ChannelLinkTarget
): stringParameters
target-
ChannelLinkTarget
- Returns
string
installation#
Build a URL for Fluxer's bot-installation flow from an application ID, with the fixed bot scope and optional unsigned 64-bit permissions
For the hosted links export, the URL starts at Fluxer's API authorization route, which redirects to the web app's installation page wherever Fluxer currently serves it. Instance links open the instance web app's installation page directly. Throws Helper for invalid IDs or options, and an alternate origin or scope is not accepted. This does not open the page, install the bot, authorize permissions or check whether the application exists
installation(
applicationId: string,
options?: InstallationLinkOptions
): stringinstallation(
applicationId: string,
options?: InstallationLinkOptions
): stringParameters
applicationId -
string optionsoptional-
InstallationLinkOptions
- Returns
string
message#
Build a hosted message URL in the supplied actual community-channel or direct-message context
Message and channel IDs must match, otherwise the call throws Helper. Private versus community context is not inferred from the message alone, and access is not checked
message(
message: MessageReference,
channel: ChannelLinkTarget
): stringmessage(
message: MessageReference,
channel: ChannelLinkTarget
): stringParameters
message-
MessageReference channel-
ChannelLinkTarget
- Returns
string
Mention#
The result of format
Read kind to identify what was mentioned and id to get its decimal ID
type Mention =
| { readonly id: string; readonly kind: "user" }
| { readonly id: string; readonly kind: "role" }
| { readonly id: string; readonly kind: "channel" }type Mention =
| {
readonly id: string
readonly kind: "user"
}
| {
readonly id: string
readonly kind: "role"
}
| {
readonly id: string
readonly kind: "channel"
}MissingMessageBody #
The type of Message before a body is selected
Calling it fails to compile with an error that names the missing argument select, which states the fix
type MissingMessageBody =
(selectContentEmbedAttachmentOrStickerBeforeBuild: never)
=> nevertype MissingMessageBody =
(
selectContentEmbedAttachmentOrStickerBeforeBuild:
never
) => neverRgbColor #
A three-item array of red, green and blue amounts, in that order
Each must be an integer from 0 through 255
type RgbColor = readonly [red: number, green: number, blue: number]type RgbColor =
readonly [
red: number,
green: number,
blue: number
]SnowflakeHelpers #
Methods of the snowflakes helper, which reads and converts decimal Fluxer IDs without losing precision
type SnowflakeHelpers = Readonly<{ … }>type SnowflakeHelpers =
Readonly<{ … }>boundary#
Make the smallest ID for a Date's exact UTC millisecond, useful as a time-based pagination boundary
Throws Helper for an invalid Date, a date before 2015-01-01 UTC or a result outside the ID range. This does not create a resource. Whether the boundary is included depends on the endpoint using it
boundary(value: Date): stringParameters
value-
Date
- Returns
string
createdAt #
Return a new UTC Date for the creation time encoded in an ID
Throws Helper for an invalid ID. This decodes the ID's high 41 timestamp bits relative to 2015-01-01 UTC, and does not fetch the resource or prove it is visible
createdAt(value: string): DateParameters
value-
string
- Returns
Date
isValid #
Return true for a decimal string from "0" through "9223372036854775807", with no extra leading zeroes
Returns false immediately for numbers, whitespace and invalid strings, without converting through Number or failing
isValid(value: unknown): value is stringisValid(
value: unknown
): value is stringParameters
value-
unknown
- Returns
value is string
parse#
Convert a valid decimal-string ID to bigint without losing precision
Throws Helper for an invalid ID. For IDs received from users, use try, which reports the same Helper without throwing
parse(value: string): bigintParameters
value-
string
- Returns
bigint
shardFor #
Return the shard that receives a community's gateway events when the bot runs total shards
Fluxer calls a community a guild, so the first argument is a guild ID. Fluxer routes each community with (guild >> 22) % total, and this helper applies the same formula. Use it to find which process owns a community when shards run in several processes. Throws Helper for an invalid ID or a total outside 1 through 16,384. It does not check whether the bot belongs to that community
shardFor(guildId: string, totalShards: number): numbershardFor(
guildId: string,
totalShards: number
): numberParameters
guildId -
string totalShards -
number
- Returns
number
tryParse #
Convert a decimal-string ID with the same rules as parse, but report an invalid ID without throwing
The default API returns a Result holding the bigint or Helper. The native API returns an Effect that reads the ID when run and fails with Helper. Use it for IDs received from users or other untrusted sources
tryParse(value: string): Result<bigint, HelperError>tryParse(value: string): Result<
bigint, HelperError
>Parameters
value-
string
- Returns
Result<bigint, HelperError>- Fails with
TextHelpers #
Methods of the text helper, which splits and truncates long strings
type TextHelpers = Readonly<{ … }>split#
Split text into a frozen array of pieces, each with string at most options UTF-16 units
Prefer the last newline within a full piece, then the last whitespace, otherwise split a long word. Whitespace stays in the preceding piece, so joining with an empty separator reconstructs the input. Each lone surrogate, such as half of an emoji left by slice, first becomes U+FFFD (�) of the same length, because Fluxer refuses a lone surrogate. The pieces then join to content. To reject such text instead, check content first. Empty text gives []
split(content: string, options: TextSplitOptions): readonly string[]split(
content: string,
options: TextSplitOptions
): readonly string[]No trimming, prefix or suffix insertion, Markdown repair, message-length lookup or remote request occurs.
Every piece ends at a grapheme boundary of Intl, so a visible character stays whole: The two UTF-16 units of a single Unicode code point,
a base character with its combining marks, a flag, a skin-tone emoji, a joined emoji and "\r\n" are never separated.
A piece can therefore be shorter than max. Only a single character longer than max is cut, between code points.
Throws Helper for text that is not a string, invalid options, or a ceiling too small for a surrogate pair.
Input and returned pieces are application-owned, and result size is proportional to the supplied text
Parameters
content-
string options-
TextSplitOptions
- Returns
readonly string[]
truncate#
Shorten text to at most options UTF-16 units, ending in options when anything was cut
Each lone surrogate, such as half of an emoji left by slice, first becomes U+FFFD (�) of the same length, because Fluxer refuses a lone surrogate. To reject such text instead, check content first. Text that then fits is returned as it is. Otherwise the text is cut so that the kept text and the suffix together fit, at a grapheme boundary of Intl, so only whole visible characters are kept: The two UTF-16 units of a single Unicode code point, a base character with its combining marks, a flag, a skin-tone emoji and a joined emoji are never separated, which can leave the result shorter than max. When the first character does not fit in the room before the suffix, or no room is left, the suffix alone is returned. The suffix defaults to "…" (U+2026), and a suffix of "" cuts without marking it
truncate(content: string, options: TextTruncateOptions): stringtruncate(
content: string,
options: TextTruncateOptions
): stringNo trimming, word boundary, Markdown repair, message-length lookup or remote request occurs.
To cut at a word boundary instead, take the first piece of text with a limit that leaves room for the suffix, and trim its end.
Throws Helper for text that is not a string.
Also throws Helper for options that are not an object with only max and suffix, a max that is not a
positive safe integer, or a suffix that is not a well-formed string of at most max units
Parameters
content-
string options-
TextTruncateOptions
- Returns
string
TimestampStyle #
One Fluxer timestamp-markup display style
type TimestampStyle =
typeof TimestampStyles[keyof typeof TimestampStyles]type TimestampStyle =
typeof TimestampStyles[
keyof typeof TimestampStyles
]