fluxer_util crate contains helper utilities that are independent of the client or structs.
Permissions
Permissions is a bitflags struct for working with Fluxer access permissions. Based on the bitflags 2 crate.
Flags
parse_permissions
Permissions. Returns an empty set on parse error.
permissions_to_string
Permissions back into a bitfield string for passing to the API.
ALL_PERMISSIONS
Permissions::all().
Flag Operations
Permissions supports standard bitflags operations:
Example: check member permissions
Example: check member permissions
Example: build a bitfield for a channel overwrite
Example: build a bitfield for a channel overwrite
SnowflakeUtil
Utilities for working with Snowflake IDs. Fluxer epoch:1 420 070 400 000 ms (January 1, 2015, 00:00:00 UTC).
date_from_snowflake
None if the ID is not a number.
timestamp_ms_from_snowflake
snowflake_from_timestamp
is_valid
true if the string is a valid Snowflake (non-empty string, parseable as u64).
Example: determine account age
Example: determine account age
Example: time-based pagination via snowflake_from_timestamp
Example: time-based pagination via snowflake_from_timestamp
CDN
URL-building functions for Fluxer media resources. Exported fromfluxer_core::util::cdn.
Base URLs
Functions
File Extension Logic
- If the hash starts with
a_- the extension is alwaysgif(animated resource). - Otherwise
CdnOptions.extensionis used, or"png"by default.
Example: get avatar URL at 128px in webp format
Example: get avatar URL at 128px in webp format
Example: custom emoji URL
Example: custom emoji URL
Formatters
Text utilities fromfluxer_util::formatters.
truncate
max_len characters. If the string is longer - the last character is replaced with … (U+2026).
Use
truncate before passing user-provided data into MessagePayload::content or EmbedBuilder fields to avoid panics when exceeding limits.escape_markdown
*, _, ~, `, |, >, #.
format_color
#RRGGBB. Clamps values above 0xFFFFFF.
format_timestamp
<t:timestamp:style>.
Example: embed with event time
Example: embed with event time
Tenor
Utilities for working with Tenor GIF links fromfluxer_util::tenor.
is_tenor_url
true if the URL is a Tenor link.
Recognizes the following formats:
https://tenor.com/view/...https://tenor.com/embed/...https://media.tenor.com/...
extract_tenor_id
Returns
None if the ID is not found or is not a number.
tenor_media_url
resolve_tenor_to_image_url
extract_tenor_id and tenor_media_url. Accepts a Tenor share/embed URL and returns a direct link to the GIF. Returns None if the URL is not recognized.
Example: handle a Tenor link in a message
Example: handle a Tenor link in a message
Resolvers
Helper functions fromfluxer_util::resolvers for working with colors.
resolve_color
"#RRGGBB" and "RRGGBB" formats.
resolve_color_rgb
Emoji
Utilities fromfluxer_util::emoji for emoji formatting.
format_emoji
parse_emoji_str
(name, id, animated).
