Module serenity::utils[][src]

A set of utilities to help with common use cases that are not required to fully use the library.

Structs

Colour

A utility struct to help with working with the basic representation of a colour. This is particularly useful when working with a Role's colour, as the API works with an integer value instead of an RGB value.

Content

Describes formatting on string content

MessageBuilder

The Message Builder is an ergonomic utility to easily build a message, by adding text and mentioning mentionable structs.

VecMap

Like HashMap but solely uses a vector instead.

Enums

ContentModifier

Formatting modifiers for MessageBuilder content pushes

Functions

hashmap_to_json_map

Converts a HashMap into a final serde_json::Map representation.

is_nsfw

Determines if a name is NSFW.

parse_channel

Retrieves an Id from a channel mention.

parse_emoji

Retrieves the name and Id from an emoji mention, in the form of an EmojiIdentifier.

parse_invite

Retrieves the "code" part of an invite out of a URL.

parse_quotes

Turns a string into a vector of string arguments, splitting by spaces, but parsing content within quotes as one individual argument.

parse_role

Retrieves an Id from a role mention.

parse_username

Retrieves an Id from a user mention.

read_image

Reads an image from a path and encodes it into base64.

shard_id

Calculates the Id of the shard responsible for a guild, given its Id and total number of shards used.

vecmap_to_json_map

Converts a VecMap into a final serde_json::Map representation.

with_cache

A function for doing automatic reading (and the releasing of the guard as well) This is particularly useful if you just want to use the cache for this one time, or don't want to be messing with the RwLock directly.

with_cache_mut

Like with_cache but as the name says, allows for modifications to be done.