Utility helper functions, generally for logging, running programs, time/date manipulation, etc. More...
Namespaces | |
| anonymous_namespace{utility.cpp} | |
Classes | |
| struct | dummy |
| Utility struct that has the same size and alignment as another but does nothing. More... | |
| struct | icon |
| Wrapper class around a variant for either iconhash or image, for API objects that have one or the other (generally iconhash when receiving, image when uploading an image) More... | |
| struct | iconhash |
| Store a 128 bit icon hash (profile picture, server icon etc) as a 128 bit binary value made of two uint64_t. More... | |
| struct | image_data |
| Image to be received or sent to API calls. More... | |
| struct | uptime |
| A class used to represent an uptime in hours, minutes, seconds and days, with helper functions to convert from time_t and display as a string. More... | |
Typedefs | |
| typedef std::function< void(const std::string &output)> | cmd_result_t |
| Callback for the results of a command executed via dpp::utility::exec. More... | |
Enumerations | |
| enum | avx_type_t : uint8_t { avx_none, avx_1, avx_2, avx_512 } |
| Supported AVX instruction set type for audio mixing. More... | |
| enum | guild_navigation_type { gnt_customize, gnt_browse, gnt_guide } |
| Guild navigation types for dpp::utility::guild_navigation() More... | |
| enum | time_format : uint8_t { tf_long_date = 'D', tf_long_datetime = 'F', tf_relative_time = 'R', tf_long_time = 'T', tf_short_date = 'd', tf_short_datetime = 'f', tf_short_time = 't' } |
| Timestamp formats for dpp::utility::timestamp() More... | |
Functions | |
| std::string DPP_EXPORT | avatar_size (uint32_t size) |
| Get the url query parameter for the cdn endpoint. More... | |
| std::string DPP_EXPORT | bot_invite_url (const snowflake bot_id, const uint64_t permissions=0, const std::vector< std::string > &scopes={"bot", "applications.commands"}) |
| Create a bot invite. More... | |
| std::string DPP_EXPORT | bytes (uint64_t c) |
| Convert a byte count to display value. More... | |
| std::string DPP_EXPORT | cdn_endpoint_url (const std::vector< image_type > &allowed_formats, const std::string &path_without_extension, const dpp::image_type format, uint16_t size, bool prefer_animated=false, bool is_animated=false) |
| Helper function to easily create discord's cdn endpoint urls. More... | |
| std::string DPP_EXPORT | cdn_endpoint_url_hash (const std::vector< image_type > &allowed_formats, const std::string &path_without_extension, const std::string &hash, const dpp::image_type format, uint16_t size, bool prefer_animated=false, bool is_animated=false) |
| Helper function to easily create discord's cdn endpoint urls. More... | |
| std::string DPP_EXPORT | cdn_endpoint_url_sticker (snowflake sticker_id, sticker_format format) |
| Helper function to easily create discord's cdn endpoint urls (specialised for stickers) More... | |
| std::string DPP_EXPORT | channel_mention (const snowflake &id) |
| Create a mentionable channel. More... | |
| std::string DPP_EXPORT | channel_url (const snowflake &guild_id, const snowflake &channel_id) |
| Create a URL for message. More... | |
| uint32_t DPP_EXPORT | cmyk (double c, double m, double y, double k) |
| Convert doubles to CMYK for sending in embeds. More... | |
| uint32_t DPP_EXPORT | cmyk (int c, int m, int y, int k) |
| Convert ints to CMYK for sending in embeds. More... | |
| std::string DPP_EXPORT | current_date_time () |
| Returns current date and time. More... | |
| std::string DPP_EXPORT | debug_dump (uint8_t *data, size_t length) |
| Output hex values of a section of memory for debugging. More... | |
| std::string DPP_EXPORT | emoji_mention (std::string_view name, snowflake id, bool is_animated=false) |
| Create a mentionable emoji. More... | |
| void DPP_EXPORT | exec (const std::string &cmd, std::vector< std::string > parameters={}, cmd_result_t callback={}) |
| Run a commandline program asynchronously. More... | |
| std::string DPP_EXPORT | file_extension (image_type type) |
| Get the file extension for an image type. More... | |
| std::string DPP_EXPORT | file_extension (sticker_format format) |
| Get the file extension for a sticker format. More... | |
| template<typename T > | |
| std::enable_if_t< std::is_same_v< T, sticker_format >, std::string > | file_extension (T format) |
| template<typename T > | |
| std::enable_if_t< std::is_same_v< T, image_type >, std::string > | file_extension (T type) |
| template std::string | file_extension< image_type > (image_type t) |
| template std::string | file_extension< sticker_format > (sticker_format t) |
| std::string DPP_EXPORT | guild_navigation (const snowflake guild_id, guild_navigation_type gnt) |
| Create a mentionable guild navigation (used in a message). More... | |
| bool DPP_EXPORT | has_voice () |
| Returns true if D++ was built with voice support. More... | |
| uint32_t DPP_EXPORT | hsl (double h, double s, double l) |
| Convert doubles to HSL for sending in embeds. More... | |
| uint32_t DPP_EXPORT | hsl (int h, int s, int l) |
| Convert ints to HSL for sending in embeds. More... | |
| bool DPP_EXPORT | is_coro_enabled () |
| Returns true if D++ was built with coroutine support. More... | |
| command_completion_event_t DPP_EXPORT | log_error () |
| The default callback handler for API calls. More... | |
| std::string DPP_EXPORT | loglevel (dpp::loglevel in) |
| Convert a dpp::loglevel enum value to a string. More... | |
| std::string DPP_EXPORT | make_url_parameters (const std::map< std::string, std::string > ¶meters) |
| Build a URL parameter string e.g. More... | |
| std::string DPP_EXPORT | make_url_parameters (const std::map< std::string, uint64_t > ¶meters) |
| Build a URL parameter string e.g. More... | |
| std::string DPP_EXPORT | markdown_escape (const std::string &text, bool escape_code_blocks=false) |
| Escapes Discord's markdown sequences in a string. More... | |
| std::string DPP_EXPORT | message_url (const snowflake &guild_id, const snowflake &channel_id, const snowflake &message_id) |
| Create a URL for message. More... | |
| std::string DPP_EXPORT | mime_type (image_type type) |
| Get the mime type for an image type. More... | |
| std::string DPP_EXPORT | mime_type (sticker_format format) |
| Get the mime type for a sticker format. More... | |
| template<typename T > | |
| std::enable_if_t< std::is_same_v< T, sticker_format >, std::string > | mime_type (T format) |
| template<typename T > | |
| std::enable_if_t< std::is_same_v< T, image_type >, std::string > | mime_type (T type) |
| template std::string | mime_type< image_type > (image_type t) |
| template std::string | mime_type< sticker_format > (sticker_format t) |
| std::string DPP_EXPORT | read_file (const std::string &filename) |
| Read a whole file into a std::string. More... | |
| uint32_t DPP_EXPORT | rgb (double red, double green, double blue) |
| Convert doubles to RGB for sending in embeds. More... | |
| uint32_t DPP_EXPORT | rgb (int red, int green, int blue) |
| Convert ints to RGB for sending in embeds. More... | |
| std::string DPP_EXPORT | role_mention (const snowflake &id) |
| Create a mentionable role. More... | |
| void DPP_EXPORT | set_thread_name (const std::string &name) |
| Set the name of the current thread for debugging and statistical reporting. More... | |
| std::string DPP_EXPORT | slashcommand_mention (snowflake command_id, const std::string &command_name, const std::string &subcommand="") |
| Create a mentionable slashcommand (used in a message). More... | |
| std::string DPP_EXPORT | slashcommand_mention (snowflake command_id, const std::string &command_name, const std::string &subcommand_group, const std::string &subcommand) |
| Create a mentionable slashcommand (used in a message). More... | |
| std::string DPP_EXPORT | thread_url (const snowflake &guild_id, const snowflake &thread_id) |
| Create a URL for message. More... | |
| double DPP_EXPORT | time_f () |
| Return the current time with fractions of seconds. More... | |
| std::string DPP_EXPORT | timestamp (time_t ts, time_format tf=tf_short_datetime) |
| Return a mentionable timestamp (used in a message). More... | |
| std::vector< std::string > DPP_EXPORT | tokenize (std::string const &in, const char *sep="\r\n") |
| Split (tokenize) a string into a vector, using the given separators. More... | |
| std::string DPP_EXPORT | url_encode (const std::string &value) |
| Encodes a url parameter similar to php urlencode() More... | |
| std::string DPP_EXPORT | user_mention (const snowflake &id) |
| Create a mentionable user. More... | |
| std::string DPP_EXPORT | user_url (const snowflake &user_id) |
| Create a URL for message. More... | |
| size_t DPP_EXPORT | utf8len (std::string_view str) |
| Returns the length of a UTF-8 string in codepoints. More... | |
| std::string DPP_EXPORT | utf8substr (std::string_view str, size_t start, size_t length) |
| Return substring of a UTF-8 encoded string in codepoints. More... | |
| std::string_view DPP_EXPORT | utf8subview (std::string_view str, size_t start, size_t length) |
| Return subview of a UTF-8 encoded string in codepoints. More... | |
| std::string DPP_EXPORT | validate (const std::string &value, size_t _min, size_t _max, const std::string &exception_message) |
| Validate a string value In the event the length of the string is less than _min, then an exception of type dpp:length_exception will be thrown. More... | |
| std::string DPP_EXPORT | version () |
| Returns the library's version string. More... | |
| avx_type_t DPP_EXPORT | voice_avx () |
| Returns an enum value indicating which AVX instruction set is used for mixing received voice data, if any. More... | |
Variables | |
| template<typename F , typename R , typename... Args> | |
| constexpr bool | callable_returns_v = std::is_convertible_v<std::invoke_result_t<F, Args...>, R> |
| Type trait to check if a callable F can be called using the arguments Args, and that its return value is convertible to R. More... | |
| const std::string | cdn_host = "https://cdn.discordapp.com" |
| The base URL for CDN content such as profile pictures and guild icons. More... | |
| std::function< void(const dpp::log_t &)> DPP_EXPORT | cout_logger () |
| Get a default logger that outputs to std::cout. More... | |
| static const char * | hex = "0123456789ABCDEF" |
| constexpr int | max_cdn_image_size {4096} |
| constexpr int | min_cdn_image_size {16} |
| const std::string | url_host = "https://discord.com" |
| The base URL for message/user/channel links. More... | |
Utility helper functions, generally for logging, running programs, time/date manipulation, etc.
| typedef std::function<void(const std::string& output)> dpp::utility::cmd_result_t |
Callback for the results of a command executed via dpp::utility::exec.
| enum dpp::utility::avx_type_t : uint8_t |
Guild navigation types for dpp::utility::guild_navigation()
| Enumerator | |
|---|---|
| gnt_customize | Customize tab with the server's dpp::onboarding_prompt |
| gnt_browse | "16:20" Browse Channels tab |
| gnt_guide | Server Guide. |
| enum dpp::utility::time_format : uint8_t |
Timestamp formats for dpp::utility::timestamp()
| std::string dpp::utility::avatar_size | ( | uint32_t | size | ) |
Get the url query parameter for the cdn endpoint.
Internally used to build url getters.
| size | size to generate url parameter for. Must be any power of two between 16 and 4096 (inclusive) or it'll return an empty string. |
?size=128, or an empty string References max_cdn_image_size, and min_cdn_image_size.
Referenced by cdn_endpoint_url_hash().

| std::string dpp::utility::bot_invite_url | ( | const snowflake | bot_id, |
| const uint64_t | permissions = 0, |
||
| const std::vector< std::string > & | scopes = {"bot", "applications.commands"} |
||
| ) |
Create a bot invite.
| bot_id | Bot ID |
| permissions | Permission bitmask of the bot to invite |
| scopes | Scopes to use |
| std::string dpp::utility::bytes | ( | uint64_t | c | ) |
Convert a byte count to display value.
| c | number of bytes |
Referenced by dpp::utility::image_data::set().

| std::string dpp::utility::cdn_endpoint_url | ( | const std::vector< image_type > & | allowed_formats, |
| const std::string & | path_without_extension, | ||
| const dpp::image_type | format, | ||
| uint16_t | size, | ||
| bool | prefer_animated = false, |
||
| bool | is_animated = false |
||
| ) |
Helper function to easily create discord's cdn endpoint urls.
| allowed_formats | A vector of supported formats for the endpoint from the discord docs |
| path_without_extension | The path for the endpoint (without the extension e.g. .png) |
| format | the wished format to return. Must be one of the formats passed in allowed_formats, otherwise it returns an empty string |
| size | the image size which will be appended as a querystring to the url. It must be any power of two between 16 and 4096, otherwise no querystring will be appended (discord then returns the image as their default size) |
| prefer_animated | Whether the user prefers gif format. If true, it'll return gif format whenever the image is available as animated. In this case, the format-parameter is only used for non-animated images. |
| is_animated | Whether the image is actually animated or not |
References cdn_endpoint_url_hash().
Referenced by dpp::role::get_members(), and dpp::user_identified::user_identified().


| std::string dpp::utility::cdn_endpoint_url_hash | ( | const std::vector< image_type > & | allowed_formats, |
| const std::string & | path_without_extension, | ||
| const std::string & | hash, | ||
| const dpp::image_type | format, | ||
| uint16_t | size, | ||
| bool | prefer_animated = false, |
||
| bool | is_animated = false |
||
| ) |
Helper function to easily create discord's cdn endpoint urls.
| allowed_formats | A vector of supported formats for the endpoint from the discord docs |
| path_without_extension | The path for the endpoint (without the extension e.g. .png) |
| hash | The hash (optional). If not empty, it will be prefixed with a_ for animated images (is_animated=true) |
| format | the wished format to return. Must be one of the formats passed in allowed_formats, otherwise it returns an empty string |
| size | the image size which will be appended as a querystring to the url. It must be any power of two between 16 and 4096, otherwise no querystring will be appended (discord then returns the image as their default size) |
| prefer_animated | Whether the user prefers gif format. If true, it'll return gif format whenever the image is available as animated. In this case, the format-parameter is only used for non-animated images. |
| is_animated | Whether the image is actually animated or not |
References avatar_size(), cdn_host, dpp::unicode_emoji::hash, dpp::i_gif, dpp::i_jpg, dpp::i_png, and dpp::i_webp.
Referenced by cdn_endpoint_url(), dpp::guild::connect_member_voice(), and dpp::user::has_animated_icon().


| std::string dpp::utility::cdn_endpoint_url_sticker | ( | snowflake | sticker_id, |
| sticker_format | format | ||
| ) |
Helper function to easily create discord's cdn endpoint urls (specialised for stickers)
| sticker_id | The sticker ID. Returns empty string if 0 |
| format | The format type |
References cdn_host, and file_extension().

| std::string dpp::utility::channel_mention | ( | const snowflake & | id | ) |
Create a mentionable channel.
| id | The ID of the channel. |
Create a URL for message.
| guild_id | The ID of the guild where channel is located. |
| channel_id | The ID of the channel. |
References dpp::snowflake::empty(), and url_host.
Referenced by thread_url().


| uint32_t dpp::utility::cmyk | ( | double | c, |
| double | m, | ||
| double | y, | ||
| double | k | ||
| ) |
Convert doubles to CMYK for sending in embeds.
| c | cyan value, between 0 and 1 inclusive |
| m | magenta value, between 0 and 1 inclusive |
| y | yellow value, between 0 and 1 inclusive |
| k | key (black) value, between 0 and 1 inclusive |
References dpp::unicode_emoji::b, dpp::unicode_emoji::m, and rgb().
Referenced by cmyk().


| uint32_t dpp::utility::cmyk | ( | int | c, |
| int | m, | ||
| int | y, | ||
| int | k | ||
| ) |
Convert ints to CMYK for sending in embeds.
| c | cyan value, between 0 and 255 inclusive |
| m | magenta value, between 0 and 255 inclusive |
| y | yellow value, between 0 and 255 inclusive |
| k | key (black) value, between 0 and 255 inclusive |
References cmyk(), and dpp::unicode_emoji::m.

| std::string dpp::utility::current_date_time | ( | ) |
Returns current date and time.
References dpp::unicode_emoji::tm, and dpp::trim().

| std::string dpp::utility::debug_dump | ( | uint8_t * | data, |
| size_t | length | ||
| ) |
Output hex values of a section of memory for debugging.
| data | The start of the data to display |
| length | The length of data to display |
References dpp::to_hex().
Referenced by dpp::discord_client::handle_frame().


| std::string dpp::utility::emoji_mention | ( | std::string_view | name, |
| snowflake | id, | ||
| bool | is_animated = false |
||
| ) |
Create a mentionable emoji.
| name | The name of the emoji. |
| id | The ID of the emoji. |
| is_animated | is emoji animated. |
Referenced by dpp::emoji::load_image().

| void dpp::utility::exec | ( | const std::string & | cmd, |
| std::vector< std::string > | parameters = {}, |
||
| cmd_result_t | callback = {} |
||
| ) |
Run a commandline program asynchronously.
The command line program is spawned in a separate std::thread, and when complete, its output from stdout is passed to the callback function in its string parameter. For example:
| cmd | The command to run. |
| parameters | Command line parameters. Each will be escaped using std::quoted. |
| callback | The callback to call on completion. |
References set_thread_name(), and dpp::unicode_emoji::thread.

| std::string DPP_EXPORT dpp::utility::file_extension | ( | image_type | type | ) |
Get the file extension for an image type.
| type | Image type |
Referenced by dpp::utility::image_data::get_file_extension().

| std::string DPP_EXPORT dpp::utility::file_extension | ( | sticker_format | format | ) |
Get the file extension for a sticker format.
| format | Sticker format |
| std::enable_if_t<std::is_same_v<T, sticker_format>, std::string> dpp::utility::file_extension | ( | T | format | ) |
References dpp::sf_apng, dpp::sf_gif, dpp::sf_lottie, and dpp::sf_png.
Referenced by cdn_endpoint_url_sticker().

| std::enable_if_t<std::is_same_v<T, image_type>, std::string> dpp::utility::file_extension | ( | T | type | ) |
References dpp::i_gif, dpp::i_jpg, dpp::i_png, and dpp::i_webp.
| template std::string dpp::utility::file_extension< image_type > | ( | image_type | t | ) |
| template std::string dpp::utility::file_extension< sticker_format > | ( | sticker_format | t | ) |
| std::string dpp::utility::guild_navigation | ( | const snowflake | guild_id, |
| guild_navigation_type | gnt | ||
| ) |
Create a mentionable guild navigation (used in a message).
| guild_id | The guild ID |
| gnt | Guild navigation type using dpp::utility::guild_navigation_type |
References gnt_browse, gnt_customize, and gnt_guide.
| bool dpp::utility::has_voice | ( | ) |
Returns true if D++ was built with voice support.
| uint32_t dpp::utility::hsl | ( | double | h, |
| double | s, | ||
| double | l | ||
| ) |
Convert doubles to HSL for sending in embeds.
| h | hue value, between 0 and 1 inclusive |
| s | saturation value in percentage, between 0 and 1 inclusive |
| l | lightness value in percentage, between 0 and 1 inclusive |
References dpp::unicode_emoji::b, and rgb().
Referenced by hsl().


| uint32_t dpp::utility::hsl | ( | int | h, |
| int | s, | ||
| int | l | ||
| ) |
Convert ints to HSL for sending in embeds.
| h | hue value, between 0 and 360 inclusive |
| s | saturation value in percentage, between 0 and 100 inclusive |
| l | lightness value in percentage, between 0 and 100 inclusive |
References hsl().

| bool dpp::utility::is_coro_enabled | ( | ) |
Returns true if D++ was built with coroutine support.
| std::function< void(const dpp::confirmation_callback_t &detail)> dpp::utility::log_error | ( | ) |
The default callback handler for API calls.
on error, sends the error to the logger.
References dpp::error_info::human_readable, and dpp::ll_error.
| std::string dpp::utility::loglevel | ( | dpp::loglevel | in | ) |
Convert a dpp::loglevel enum value to a string.
| in | log level to convert |
References dpp::ll_critical, dpp::ll_debug, dpp::ll_error, dpp::ll_info, dpp::ll_trace, and dpp::ll_warning.
| std::string dpp::utility::make_url_parameters | ( | const std::map< std::string, std::string > & | parameters | ) |
Build a URL parameter string e.g.
"?a=b&c=d&e=f" from a map of key/value pairs. Entries with empty key names or values are omitted.
| parameters | parameters to create a url query string for |
References url_encode(), and dpp::unicode_emoji::v.
Referenced by dpp::cluster::delete_webhook(), dpp::cluster::edit_webhook_message(), dpp::cluster::guild_delete_integration(), and make_url_parameters().


| std::string dpp::utility::make_url_parameters | ( | const std::map< std::string, uint64_t > & | parameters | ) |
Build a URL parameter string e.g.
"?a=b&c=d&e=f" from a map of key/value pairs. Entries with empty key names or zero values are omitted.
| parameters | parameters to create a url query string for |
References make_url_parameters(), and dpp::unicode_emoji::v.

| std::string dpp::utility::markdown_escape | ( | const std::string & | text, |
| bool | escape_code_blocks = false |
||
| ) |
Escapes Discord's markdown sequences in a string.
| text | Text to escape |
| escape_code_blocks | If set to false, then code blocks are not escaped. This means that you can still use a code block, and the text within will be left as-is. If set to true, code blocks will also be escaped so that ` symbol may be used as a normal character. |
Represents the current state of the finite state machine for the markdown_escape function.
Normal text
A paragraph code block, represented by three backticks.
An inline code block, represented by one backtick.
Represents the current state of the finite state machine for the markdown_escape function.
Normal text
A paragraph code block, represented by three backticks.
An inline code block, represented by one backtick.
Referenced by main().

| std::string dpp::utility::message_url | ( | const snowflake & | guild_id, |
| const snowflake & | channel_id, | ||
| const snowflake & | message_id | ||
| ) |
Create a URL for message.
| guild_id | The ID of the guild where message is written. |
| channel_id | The ID of the channel where message is written. |
| message_id | The ID of the message. |
References dpp::snowflake::empty(), and url_host.

| std::string DPP_EXPORT dpp::utility::mime_type | ( | image_type | type | ) |
Get the mime type for an image type.
| type | Image type |
Referenced by dpp::utility::image_data::get_mime_type().

| std::string DPP_EXPORT dpp::utility::mime_type | ( | sticker_format | format | ) |
Get the mime type for a sticker format.
| format | Sticker format |
| std::enable_if_t<std::is_same_v<T, sticker_format>, std::string> dpp::utility::mime_type | ( | T | format | ) |
References dpp::sf_apng, dpp::sf_gif, dpp::sf_lottie, and dpp::sf_png.
| std::enable_if_t<std::is_same_v<T, image_type>, std::string> dpp::utility::mime_type | ( | T | type | ) |
References dpp::i_gif, dpp::i_jpg, dpp::i_png, and dpp::i_webp.
| template std::string dpp::utility::mime_type< image_type > | ( | image_type | t | ) |
| template std::string dpp::utility::mime_type< sticker_format > | ( | sticker_format | t | ) |
| std::string dpp::utility::read_file | ( | const std::string & | filename | ) |
Read a whole file into a std::string.
| filename | The path to the file to read |
| dpp::file_exception | on failure to read the entire file |
| uint32_t dpp::utility::rgb | ( | double | red, |
| double | green, | ||
| double | blue | ||
| ) |
Convert doubles to RGB for sending in embeds.
| red | red value, between 0 and 1 inclusive |
| green | green value, between 0 and 1 inclusive |
| blue | blue value, between 0 and 1 inclusive |
References dpp::colors::blue, dpp::colors::green, and dpp::colors::red.
Referenced by cmyk(), and hsl().

| uint32_t dpp::utility::rgb | ( | int | red, |
| int | green, | ||
| int | blue | ||
| ) |
Convert ints to RGB for sending in embeds.
| red | red value, between 0 and 255 inclusive |
| green | green value, between 0 and 255 inclusive |
| blue | blue value, between 0 and 255 inclusive |
References dpp::colors::blue, dpp::colors::green, and dpp::colors::red.
| std::string dpp::utility::role_mention | ( | const snowflake & | id | ) |
Create a mentionable role.
| id | The ID of the role. |
| void dpp::utility::set_thread_name | ( | const std::string & | name | ) |
Set the name of the current thread for debugging and statistical reporting.
| name | New name to set |
Referenced by exec().

| std::string dpp::utility::slashcommand_mention | ( | snowflake | command_id, |
| const std::string & | command_name, | ||
| const std::string & | subcommand = "" |
||
| ) |
Create a mentionable slashcommand (used in a message).
| command_id | The ID of the slashcommand |
| command_name | The command name |
| subcommand | Optional: The subcommand name (for mentioning a subcommand) |
Referenced by dpp::interaction::get_channel(), and dpp::interaction::get_context_message().

| std::string dpp::utility::slashcommand_mention | ( | snowflake | command_id, |
| const std::string & | command_name, | ||
| const std::string & | subcommand_group, | ||
| const std::string & | subcommand | ||
| ) |
Create a mentionable slashcommand (used in a message).
| command_id | The ID of the slashcommand |
| command_name | The command name |
| subcommand_group | The subcommand group name |
| subcommand | The subcommand name |
Create a URL for message.
| guild_id | The ID of the guild where thread is located. |
| thread_id | The ID of the thread. |
References channel_url().

| double dpp::utility::time_f | ( | ) |
Return the current time with fractions of seconds.
This is a unix epoch time with the fractional seconds part after the decimal place.
Referenced by dpp::connect_with_timeout(), get_time(), dpp::discord_client::handle_frame(), main(), and dpp::discord_client::one_second_timer().

| std::string dpp::utility::timestamp | ( | time_t | ts, |
| time_format | tf = tf_short_datetime |
||
| ) |
Return a mentionable timestamp (used in a message).
These timestamps will display the given timestamp in the user's timezone and locale.
| ts | Time stamp to convert |
| tf | Format of timestamp using dpp::utility::time_format |
Referenced by dpp::set_ts_not_null(), and dpp::ts_not_null().

| std::vector< std::string > dpp::utility::tokenize | ( | std::string const & | in, |
| const char * | sep = "\r\n" |
||
| ) |
Split (tokenize) a string into a vector, using the given separators.
| in | Input string |
| sep | Separator characters |
References dpp::unicode_emoji::b.
Referenced by dpp::https_client::handle_buffer().

| std::string dpp::utility::url_encode | ( | const std::string & | value | ) |
Encodes a url parameter similar to php urlencode()
| value | String to encode |
References hex.
Referenced by dpp::cluster::get_channel_webhooks(), dpp::cluster::guild_command_get_permissions(), dpp::cluster::guild_commands_get(), dpp::cluster::interaction_followup_create(), dpp::cluster::interaction_followup_edit_original(), dpp::cluster::interaction_response_create(), dpp::cluster::interaction_response_edit(), dpp::cluster::interaction_response_get_original(), main(), make_url_parameters(), and dpp::cluster::message_delete_own_reaction().

| std::string dpp::utility::user_mention | ( | const snowflake & | id | ) |
Create a mentionable user.
| id | The ID of the user. |
| std::string dpp::utility::user_url | ( | const snowflake & | user_id | ) |
Create a URL for message.
| user_id | The ID of the guild where thread is located. |
References dpp::snowflake::empty(), and url_host.

| size_t dpp::utility::utf8len | ( | std::string_view | str | ) |
Returns the length of a UTF-8 string in codepoints.
| str | string to count length of |
Referenced by dpp::commandhandler::register_commands(), and validate().

| std::string dpp::utility::utf8substr | ( | std::string_view | str, |
| size_t | start, | ||
| size_t | length | ||
| ) |
Return substring of a UTF-8 encoded string in codepoints.
| str | string to return substring from |
| start | start codepoint offset |
| length | length in codepoints |
References start, and utf8subview().
Referenced by dpp::select_option::set_animated(), dpp::embed::set_description(), dpp::embed::set_video(), dpp::slashcommand::to_json_impl(), and validate().


| std::string_view dpp::utility::utf8subview | ( | std::string_view | str, |
| size_t | start, | ||
| size_t | length | ||
| ) |
Return subview of a UTF-8 encoded string in codepoints.
| str | string to return substring from |
| start | start codepoint offset |
| length | length in codepoints |
References start.
Referenced by dpp::commandhandler::register_commands(), and utf8substr().

| std::string dpp::utility::validate | ( | const std::string & | value, |
| size_t | _min, | ||
| size_t | _max, | ||
| const std::string & | exception_message | ||
| ) |
Validate a string value In the event the length of the string is less than _min, then an exception of type dpp:length_exception will be thrown.
If the string is longer than _max UTF8 codepoints it will be truncated to fit.
| value | The value to validate |
| _min | Minimum length |
| _max | Maximum length |
| exception_message | Exception message to throw if value length < _min |
| dpp::length_exception | if value UTF8 length < _min |
References utf8len(), and utf8substr().
Referenced by dpp::role::has_view_creator_monetization_analytics(), and dpp::scheduled_event::scheduled_event().


| std::string dpp::utility::version | ( | ) |
| avx_type_t dpp::utility::voice_avx | ( | ) |
|
inlineconstexpr |
Type trait to check if a callable F can be called using the arguments Args, and that its return value is convertible to R.
| F | Callable object |
| R | Return type to check for convertibility to |
| Args... | Arguments to use to resolve the overload |
F(Args...) is convertible to R
|
inline |
The base URL for CDN content such as profile pictures and guild icons.
Referenced by cdn_endpoint_url_hash(), and cdn_endpoint_url_sticker().
| std::function< void(const dpp::log_t &)> dpp::utility::cout_logger |
Get a default logger that outputs to std::cout.
e.g.
Referenced by main().
|
static |
Referenced by dpp::utility::iconhash::set(), and url_encode().
|
constexpr |
Referenced by avatar_size().
|
constexpr |
Referenced by avatar_size().
|
inline |
The base URL for message/user/channel links.
Referenced by channel_url(), message_url(), and user_url().