1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-01 14:37:10 +02:00

Update WIP discord and some vendors.

CPR has features disabled and PCRE is fully disabled until updated to new code.
This commit is contained in:
Sandu Liviu Catalin
2023-08-05 21:31:33 +03:00
parent e0761bf3b9
commit 9298065cef
1562 changed files with 55070 additions and 76299 deletions

View File

@ -105,7 +105,7 @@ struct DPP_EXPORT command_option_choice : public json_interface<command_option_c
/**
* @brief Add a localisation for this command option choice
* @see https://discord.com/developers/docs/reference#locales
* @param language Name of language, see the list of locales linked to above.
* @param language Name of language, see the list of locales linked to above
* @param _name name of command option choice in the specified language
* @return command_option_choice& reference to self for fluent chaining
*/
@ -139,7 +139,8 @@ struct DPP_EXPORT command_option_choice : public json_interface<command_option_c
void to_json(nlohmann::json& j, const command_option_choice& choice);
/**
* @brief A minimum or maximum value for co_number and co_integer dpp::command_option types
* @brief A minimum or maximum value/length for dpp::co_number, dpp::co_integer and dpp::co_string types of a dpp::command_option.
* The `int64_t` is for the integer range or string length that can be entered. The `double` is for the decimal range that can be entered
*/
typedef std::variant<std::monostate, int64_t, double> command_option_range;
@ -162,8 +163,9 @@ struct DPP_EXPORT command_option : public json_interface<command_option> {
bool autocomplete; //!< True if this option supports auto completion
std::vector<command_option> options; //!< Sub-commands
std::vector<channel_type> channel_types; //!< Allowed channel types for channel snowflake id options
command_option_range min_value; //!< Minimum value allowed, for co_number and co_integer types only
command_option_range max_value; //!< Maximum value allowed, for co_number and co_integer types only
// Combines the `min_length` and `max_length` field by storing its value in the int64_t of the command_option_range
command_option_range min_value; //!< Minimum value/length that can be entered, for dpp::co_number, dpp::co_integer and dpp::co_string types only
command_option_range max_value; //!< Maximum value/length that can be entered, for dpp::co_number, dpp::co_integer and dpp::co_string types only
std::map<std::string, std::string> name_localizations; //!< Localisations of command name
std::map<std::string, std::string> description_localizations; //!< Localisations of command description
@ -181,12 +183,12 @@ struct DPP_EXPORT command_option : public json_interface<command_option> {
/**
* @brief Add a localisation for this slash command option
* @see https://discord.com/developers/docs/reference#locales
* @param language Name of language, see the list of locales linked to above.
* @param language Name of language, see the list of locales linked to above
* @param _name name of slash command option in the specified language
* @param _description description of slash command option in the specified language
* @param _description description of slash command option in the specified language (optional)
* @return command_option& reference to self for fluent chaining
*/
command_option& add_localization(const std::string& language, const std::string& _name, const std::string& _description);
command_option& add_localization(const std::string& language, const std::string& _name, const std::string& _description = "");
/**
* @brief Construct a new command option object
@ -203,39 +205,39 @@ struct DPP_EXPORT command_option : public json_interface<command_option> {
*
* @param o choice to add
* @return command_option& returns a reference to self for chaining of calls
* @throw dpp::exception command_option is an autocomplete, so choices cannot be added
* @throw dpp::logic_exception command_option is an autocomplete, so choices cannot be added
*/
command_option& add_choice(const command_option_choice &o);
/**
* @brief Set the minimum numeric value of the option.
* Only valid if the type is co_number or co_integer.
* Only valid if the type is dpp::co_number or dpp::co_integer.
* @param min_v Minimum value
* @return command_option& return a reference to sef for chaining of calls
* @return command_option& returns a reference to self for chaining of calls
*/
command_option& set_min_value(command_option_range min_v);
/**
* @brief Set the maximum numeric value of the option.
* Only valid if the type is co_number or co_integer.
* Only valid if the type is dpp::co_number or dpp::co_integer.
* @param max_v Maximum value
* @return command_option& return a reference to sef for chaining of calls
* @return command_option& returns a reference to self for chaining of calls
*/
command_option& set_max_value(command_option_range max_v);
/**
* @brief Set the minimum string length of the option.
* Only valid if the type is co_string
* @brief Set the minimum string length of the option. Must be between 0 and 6000 (inclusive).
* Only valid if the type is dpp::co_string
* @param min_v Minimum value
* @return command_option& return a reference to sef for chaining of calls
* @return command_option& returns a reference to self for chaining of calls
*/
command_option& set_min_length(command_option_range min_v);
/**
* @brief Set the maximum string length of the option.
* Only valid if the type is co_string
* @brief Set the maximum string length of the option. Must be between 1 and 6000 (inclusive).
* Only valid if the type is dpp::co_string
* @param max_v Maximum value
* @return command_option& return a reference to sef for chaining of calls
* @return command_option& returns a reference to self for chaining of calls
*/
command_option& set_max_length(command_option_range max_v);
@ -260,7 +262,7 @@ struct DPP_EXPORT command_option : public json_interface<command_option> {
*
* @param autocomp True to enable auto completion for this option
* @return command_option& return a reference to self for chaining of calls
* @throw dpp::exception You attempted to enable auto complete on a command_option that has choices added to it
* @throw dpp::logic_exception You attempted to enable auto complete on a command_option that has choices added to it
*/
command_option& set_auto_complete(bool autocomp);
@ -528,8 +530,8 @@ struct DPP_EXPORT command_data_option {
/**
* @brief Get an option value by index
*
* @tparam Type to get from the parameter
* @param index index number of parameter
* @tparam T Type to get from the parameter
* @param index index of the option
* @return T returned type
*/
template <typename T> T& get_value(size_t index) {
@ -582,8 +584,8 @@ struct DPP_EXPORT command_interaction {
/**
* @brief Get an option value by index
*
* @tparam Type to get from the parameter
* @param index index number of parameter
* @tparam T Type to get from the parameter
* @param index index of the option
* @return T returned type
*/
template <typename T> T& get_value(size_t index) {
@ -685,15 +687,16 @@ public:
std::variant<command_interaction, component_interaction, autocomplete_interaction> data; //!< Optional: the command data payload
snowflake guild_id; //!< Optional: the guild it was sent from
snowflake channel_id; //!< Optional: the channel it was sent from
dpp::channel channel; //!< Optional: The partial channel object where it was sent from
snowflake message_id; //!< Originating message id for context menu actions
permission app_permissions; //!< Permissions of the bot in the channel/guild where this command was issued
message msg; //!< Originating message for context menu actions
guild_member member; //!< Optional: guild member data for the invoking user, including permissions
guild_member member; //!< Optional: guild member data for the invoking user, including permissions. Filled when the interaction is invoked in a guild
user usr; //!< User object for the invoking user
std::string token; //!< a continuation token for responding to the interaction
uint8_t version; //!< read-only property, always 1
command_resolved resolved; //!< Resolved user/role etc
std::string locale; //!< User's locale (language)
std::string locale; //!< User's [locale](https://discord.com/developers/docs/reference#locales) (language)
std::string guild_locale; //!< Guild's locale (language) - for guild interactions only
cache_policy_t cache_policy; //!< Cache policy from cluster
@ -1076,12 +1079,12 @@ public:
/**
* @brief Add a localisation for this slash command
* @see https://discord.com/developers/docs/reference#locales
* @param language Name of language, see the list of locales linked to above.
* @param language Name of language, see the list of locales linked to above
* @param _name name of slash command in the specified language
* @param _description description of slash command in the specified language
* @return slashcommand& reference to self for fluent chaining
* @param _description description of slash command in the specified language (optional)
* @return slashcommand& reference to self for chaining of calls
*/
slashcommand& add_localization(const std::string& language, const std::string& _name, const std::string& _description);
slashcommand& add_localization(const std::string& language, const std::string& _name, const std::string& _description = "");
/**
* @brief Set the dm permission for the command

View File

@ -45,6 +45,8 @@ enum team_member_status : uint8_t {
* @brief Flags for a bot or application
*/
enum application_flags : uint32_t {
/// Indicates if an app uses the Auto Moderation API
apf_application_automod_rule_create_badge = (1 << 6),
/// Has gateway presence intent
apf_gateway_presence = (1 << 12),
/// Has gateway presence intent for <100 guilds

View File

@ -177,7 +177,7 @@ struct DPP_EXPORT audit_extra {
/**
* @brief An individual audit log entry
*/
struct DPP_EXPORT audit_entry {
struct DPP_EXPORT audit_entry : public json_interface<audit_entry> {
snowflake id; //!< id of the entry
/**
* ID of the affected entity (webhook, user, role, etc.) (may be empty)
@ -189,6 +189,18 @@ struct DPP_EXPORT audit_entry {
audit_type type; //!< type of action that occurred
std::optional<audit_extra> extra; //!< Optional: additional info for certain action types
std::string reason; //!< Optional: the reason for the change (1-512 characters)
/** Constructor */
audit_entry();
/** Destructor */
virtual ~audit_entry() = default;
/** Read class values from json object
* @param j A json object to read from
* @return A reference to self
*/
audit_entry& fill_from_json(nlohmann::json* j);
};
/**

View File

@ -82,7 +82,7 @@ enum automod_event_type : uint8_t {
*/
enum automod_trigger_type : uint8_t {
/**
* @brief Check if content contains words from a user defined list of keywords
* @brief Check if content contains words from a user defined list of keywords (max 6 of this type per guild)
*/
amod_type_keyword = 1,
/**
@ -91,21 +91,21 @@ enum automod_trigger_type : uint8_t {
*/
amod_type_harmful_link = 2,
/**
* @brief Check if content represents generic spam
* @brief Check if content represents generic spam (max 1 of this type per guild)
*/
amod_type_spam = 3,
/**
* @brief Check if content contains words from discord pre-defined wordsets
* @brief Check if content contains words from discord pre-defined wordsets (max 1 of this type per guild)
*/
amod_type_keyword_preset = 4,
/**
* @brief Check if content contains more mentions than allowed
* @brief Check if content contains more mentions than allowed (max 1 of this type per guild)
*/
amod_type_mention_spam = 5,
};
/**
* @brief Metadata associated with an automod action
* @brief Metadata associated with an automod action. Different fields are relevant based on the value of dpp::automod_rule::trigger_type.
*/
struct DPP_EXPORT automod_metadata : public json_interface<automod_metadata> {
/**
@ -164,7 +164,7 @@ struct DPP_EXPORT automod_metadata : public json_interface<automod_metadata> {
std::vector<automod_preset_type> presets;
/**
* @brief Substrings which should not trigger the rule.
* @brief Substrings which should not trigger the rule (Maximum of 100 for the trigger type dpp::amod_type_keyword, Maximum of 1000 for the trigger type dpp::amod_type_keyword_preset).
*
* Each keyword can be a phrase which contains multiple words.
* All keywords are case insensitive and can be up to 60 characters.
@ -209,6 +209,11 @@ struct DPP_EXPORT automod_metadata : public json_interface<automod_metadata> {
*/
uint8_t mention_total_limit;
/**
* @brief Whether to automatically detect mention raids
*/
bool mention_raid_protection_enabled;
/**
* @brief Construct a new automod metadata object
*/

View File

@ -60,7 +60,8 @@ public:
std::string build_json(bool with_id = false) const;
};
/** A group of bans
/**
* A group of bans. The key is the user ID
*/
typedef std::unordered_map<snowflake, ban> ban_map;

View File

@ -249,7 +249,9 @@ struct DPP_EXPORT forum_tag : public managed {
forum_tag& set_name(const std::string& name);
};
/** @brief A group of thread member objects*/
/**
* @brief A group of thread member objects. the key is the thread_id of the dpp::thread_member
*/
typedef std::unordered_map<snowflake, thread_member> thread_member_map;
/**
@ -809,5 +811,13 @@ typedef std::unordered_map<snowflake, channel> channel_map;
*/
typedef std::unordered_map<snowflake, thread> thread_map;
/**
* @brief A group of threads and thread_members. returned from the cluster::threads_get_active method
*/
typedef struct {
thread_map threads;
thread_member_map thread_members;
} active_threads;
};

File diff suppressed because it is too large Load Diff

View File

@ -303,7 +303,9 @@ confirmation interaction_response_edit_sync(const std::string &token, const mess
/**
* @brief Create a followup message to a slash command
*
*
* @see dpp::cluster::interaction_followup_create
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
* @param token Token for the interaction webhook
* @param m followup message to create
* @return confirmation returned object on completion
@ -331,8 +333,10 @@ confirmation interaction_followup_create_sync(const std::string &token, const me
confirmation interaction_followup_edit_original_sync(const std::string &token, const message &m);
/**
* @brief
*
* @brief Delete the initial interaction response
*
* @see dpp::cluster::interaction_followup_delete
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response
* @param token Token for the interaction webhook
* @return confirmation returned object on completion
* \memberof dpp::cluster
@ -345,6 +349,9 @@ confirmation interaction_followup_delete_sync(const std::string &token);
/**
* @brief Edit followup message to a slash command
* The message ID in the message you pass should be correctly set to that of a followup message you previously sent
*
* @see dpp::cluster::interaction_followup_edit
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message
* @param token Token for the interaction webhook
* @param m message to edit, the ID should be set
* @return confirmation returned object on completion
@ -357,6 +364,9 @@ confirmation interaction_followup_edit_sync(const std::string &token, const mess
/**
* @brief Get the followup message to a slash command
*
* @see dpp::cluster::interaction_followup_get
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message
* @param token Token for the interaction webhook
* @param message_id message to retrieve
* @return message returned object on completion
@ -693,7 +703,7 @@ confirmation guild_emoji_delete_sync(snowflake guild_id, snowflake emoji_id);
*
* You must ensure that the emoji passed contained image data using the emoji::load_image() method.
* @see dpp::cluster::guild_emoji_edit
* @see https://discord.com/developers/docs/resources/emoji#get-guild-emoji
* @see https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param guild_id Guild ID to edit emoji on
* @param newemoji Emoji to edit
@ -724,7 +734,7 @@ emoji guild_emoji_get_sync(snowflake guild_id, snowflake emoji_id);
* @brief Get all emojis for a guild
*
* @see dpp::cluster::guild_emojis_get
* @see https://discord.com/developers/docs/resources/emoji#get-guild-emojis
* @see https://discord.com/developers/docs/resources/emoji#list-guild-emojis
* @param guild_id Guild ID to get emojis for
* @return emoji_map returned object on completion
* \memberof dpp::cluster
@ -1923,7 +1933,7 @@ dtemplate template_get_sync(const std::string &code);
/**
* @brief Join a thread
* @see dpp::cluster::current_user_join_thread
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#join-thread
* @param thread_id Thread ID to join
* @return confirmation returned object on completion
* \memberof dpp::cluster
@ -1936,7 +1946,7 @@ confirmation current_user_join_thread_sync(snowflake thread_id);
/**
* @brief Leave a thread
* @see dpp::cluster::current_user_leave_thread
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#leave-thread
* @param thread_id Thread ID to leave
* @return confirmation returned object on completion
* \memberof dpp::cluster
@ -1947,22 +1957,22 @@ confirmation current_user_join_thread_sync(snowflake thread_id);
confirmation current_user_leave_thread_sync(snowflake thread_id);
/**
* @brief Get active threads in a guild (Sorted by ID in descending order)
* @brief Get all active threads in the guild, including public and private threads. Threads are ordered by their id, in descending order.
* @see dpp::cluster::threads_get_active
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/guild#list-active-guild-threads
* @param guild_id Guild to get active threads for
* @return thread_map returned object on completion
* @return active_threads returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
thread_map threads_get_active_sync(snowflake guild_id);
active_threads threads_get_active_sync(snowflake guild_id);
/**
* @brief Get private archived threads in a channel which current user has joined (Sorted by ID in descending order)
* @see dpp::cluster::threads_get_joined_private_archived
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads
* @param channel_id Channel to get public archived threads for
* @param before_id Get threads before this id
* @param limit Number of threads to get
@ -1977,7 +1987,7 @@ thread_map threads_get_joined_private_archived_sync(snowflake channel_id, snowfl
/**
* @brief Get private archived threads in a channel (Sorted by archive_timestamp in descending order)
* @see dpp::cluster::threads_get_private_archived
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#list-private-archived-threads
* @param channel_id Channel to get public archived threads for
* @param before_timestamp Get threads before this timestamp
* @param limit Number of threads to get
@ -1992,7 +2002,7 @@ thread_map threads_get_private_archived_sync(snowflake channel_id, time_t befor
/**
* @brief Get public archived threads in a channel (Sorted by archive_timestamp in descending order)
* @see dpp::cluster::threads_get_public_archived
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#list-public-archived-threads
* @param channel_id Channel to get public archived threads for
* @param before_timestamp Get threads before this timestamp
* @param limit Number of threads to get
@ -2007,7 +2017,7 @@ thread_map threads_get_public_archived_sync(snowflake channel_id, time_t before_
/**
* @brief Get a thread member
* @see dpp::cluster::thread_member_get
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#get-thread-member
* @param thread_id Thread to get member for
* @param user_id ID of the user to get
* @return thread_member returned object on completion
@ -2021,7 +2031,7 @@ thread_member thread_member_get_sync(const snowflake thread_id, const snowflake
/**
* @brief Get members of a thread
* @see dpp::cluster::thread_members_get
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#list-thread-members
* @param thread_id Thread to get members for
* @return thread_member_map returned object on completion
* \memberof dpp::cluster
@ -2056,7 +2066,7 @@ thread thread_create_in_forum_sync(const std::string& thread_name, snowflake cha
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
*
* @see dpp::cluster::thread_create
* @see https://discord.com/developers/docs/resources/guild#create-guild-channel
* @see https://discord.com/developers/docs/resources/channel#start-thread-without-message
* @param thread_name Name of the thread
* @param channel_id Channel in which thread to create
* @param auto_archive_duration Duration after which thread auto-archives. Can be set to - 60, 1440 (for boosted guilds can also be: 4320, 10080)
@ -2075,7 +2085,7 @@ thread thread_create_sync(const std::string& thread_name, snowflake channel_id,
* @brief Create a thread with a message (Discord: ID of a thread is same as message ID)
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @see dpp::cluster::thread_create_with_message
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#start-thread-from-message
* @param thread_name Name of the thread
* @param channel_id Channel in which thread to create
* @param message_id message to start thread with
@ -2092,7 +2102,7 @@ thread thread_create_with_message_sync(const std::string& thread_name, snowflake
/**
* @brief Add a member to a thread
* @see dpp::cluster::thread_member_add
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#add-thread-member
* @param thread_id Thread ID to add to
* @param user_id Member ID to add
* @return confirmation returned object on completion
@ -2106,7 +2116,7 @@ confirmation thread_member_add_sync(snowflake thread_id, snowflake user_id);
/**
* @brief Remove a member from a thread
* @see dpp::cluster::thread_member_remove
* @see https://discord.com/developers/docs/topics/threads
* @see https://discord.com/developers/docs/resources/channel#remove-thread-member
* @param thread_id Thread ID to remove from
* @param user_id Member ID to remove
* @return confirmation returned object on completion

View File

@ -75,6 +75,670 @@ namespace dpp {
aquamarine = 0x7FFFD4,
blue_green = 0x088F8F,
raspberry = 0xE30B5C,
scarlet_red = 0xFF2400;
scarlet_red = 0xFF2400,
night = 0x0C090A,
charcoal = 0x34282C,
oil = 0x3B3131,
light_black = 0x454545,
black_cat = 0x413839,
iridium = 0x3D3C3A,
black_eel = 0x463E3F,
black_cow = 0x4C4646,
gray_wolf = 0x504A4B,
grey_wolf = 0x504A4B,
vampire_gray = 0x565051,
vampire_grey = 0x565051,
iron_gray = 0x52595D,
iron_grey = 0x52595D,
gray_dolphin = 0x5C5858,
grey_dolphin = 0x5C5858,
carbon_gray = 0x625D5D,
carbon_grey = 0x625D5D,
ash_gray = 0x666362,
ash_grey = 0x666362,
dim_gray = 0x696969,
dim_grey = 0x696969,
nardo_gray = 0x686A6C,
nardo_grey = 0x686A6C,
cloudy_gray = 0x6D6968,
cloudy_grey = 0x6D6968,
smokey_gray = 0x726E6D,
smokey_grey = 0x726E6D,
alien_gray = 0x736F6E,
alien_grey = 0x736F6E,
sonic_silver = 0x757575,
platinum_gray = 0x797979,
platinum_grey = 0x797979,
granite = 0x837E7C,
battleship_gray = 0x848482,
battleship_grey = 0x848482,
gunmetal_gray = 0x8D918D,
gunmetal_grey = 0x8D918D,
gray_cloud = 0xB6B6B4,
grey_cloud = 0xB6B6B4,
silver = 0xC0C0C0,
pale_silver = 0xC9C0BB,
gray_goose = 0xD1D0CE,
grey_goose = 0xD1D0CE,
platinum_silver = 0xCECECE,
silver_white = 0xDADBDD,
gainsboro = 0xDCDCDC,
platinum = 0xE5E4E2,
metallic_silver = 0xBCC6CC,
blue_gray = 0x98AFC7,
blue_grey = 0x98AFC7,
roman_silver = 0x838996,
light_slate_gray = 0x778899,
light_slate_grey = 0x778899,
slate_gray = 0x708090,
slate_grey = 0x708090,
rat_gray = 0x6D7B8D,
slate_granite_gray = 0x657383,
slate_granite_grey = 0x657383,
jet_gray = 0x616D7E,
jet_grey = 0x616D7E,
mist_blue = 0x646D7E,
marble_blue = 0x566D7E,
slate_blue_grey = 0x737CA1,
slate_blue_gray = 0x737CA1,
light_purple_blue = 0x728FCE,
azure_blue = 0x4863A0,
blue_jay = 0x2B547E,
charcoal_blue = 0x36454F,
dark_blue_grey = 0x29465B,
dark_slate = 0x2B3856,
deep_sea_blue = 0x123456,
night_blue = 0x151B54,
midnight_blue = 0x191970,
navy = 0x000080,
denim_dark_blue = 0x151B8D,
dark_blue = 0x00008B,
lapis_blue = 0x15317E,
new_midnight_blue = 0x0000A0,
earth_blue = 0x0000A5,
cobalt_blue = 0x0020C2,
medium_blue = 0x0000CD,
blueberry_blue = 0x0041C2,
canary_blue = 0x2916F5,
samco_blue = 0x0002FF,
bright_blue = 0x0909FF,
blue_orchid = 0x1F45FC,
sapphire_blue = 0x2554C7,
blue_eyes = 0x1569C7,
bright_navy_blue = 0x1974D2,
balloon_blue = 0x2B60DE,
royal_blue = 0x4169E1,
ocean_blue = 0x2B65EC,
blue_ribbon = 0x306EFF,
blue_dress = 0x157DEC,
neon_blue = 0x1589FF,
dodger_blue = 0x1E90FF,
glacial_blue_ice = 0x368BC1,
steel_blue = 0x4682B4,
silk_blue = 0x488AC7,
windows_blue = 0x357EC7,
blue_ivy = 0x3090C7,
blue_koi = 0x659EC7,
columbia_blue = 0x87AFC7,
baby_blue = 0x95B9C7,
cornflower_blue = 0x6495ED,
sky_blue_dress = 0x6698FF,
iceberg = 0x56A5EC,
butterfly_blue = 0x38ACEC,
deep_sky_blue = 0x00BFFF,
midday_blue = 0x3BB9FF,
crystal_blue = 0x5CB3FF,
denim_blue = 0x79BAEC,
day_sky_blue = 0x82CAFF,
light_sky_blue = 0x87CEFA,
sky_blue = 0x87CEEB,
jeans_blue = 0xA0CFEC,
blue_angel = 0xB7CEEC,
pastel_blue = 0xB4CFEC,
light_day_blue = 0xADDFFF,
sea_blue = 0xC2DFFF,
heavenly_blue = 0xC6DEFF,
robin_egg_blue = 0xBDEDFF,
powder_blue = 0xB0E0E6,
coral_blue = 0xAFDCEC,
light_blue = 0xADD8E6,
light_steel_blue = 0xB0CFDE,
gulf_blue = 0xC9DFEC,
pastel_light_blue = 0xD5D6EA,
lavender_blue = 0xE3E4FA,
white_blue = 0xDBE9FA,
lavender = 0xE6E6FA,
water = 0xEBF4FA,
alice_blue = 0xF0F8FF,
ghost_white = 0xF8F8FF,
azure = 0xF0FFFF,
light_cyan = 0xE0FFFF,
light_slate = 0xCCFFFF,
electric_blue = 0x9AFEFF,
tron_blue = 0x7DFDFE,
blue_zircon = 0x57FEFF,
aqua = 0x00FFFF,
bright_cyan = 0x0AFFFF,
celeste = 0x50EBEC,
blue_diamond = 0x4EE2EC,
bright_turquoise = 0x16E2F5,
blue_lagoon = 0x8EEBEC,
pale_turquoise = 0xAFEEEE,
pale_blue_lily = 0xCFECEC,
light_teal = 0xB3D9D9,
tiffany_blue = 0x81D8D0,
blue_hosta = 0x77BFC7,
cyan_opaque = 0x92C7C7,
northern_lights_blue = 0x78C7C7,
medium_aquamarine = 0x66CDAA,
magic_mint = 0xAAF0D1,
light_aquamarine = 0x93FFE8,
bright_teal = 0x01F9C6,
turquoise = 0x40E0D0,
medium_turquoise = 0x48D1CC,
deep_turquoise = 0x48CCCD,
jellyfish = 0x46C7C7,
blue_turquoise = 0x43C6DB,
dark_turquoise = 0x00CED1,
macaw_blue_green = 0x43BFC7,
seafoam_green = 0x3EA99F,
cadet_blue = 0x5F9EA0,
blue_chill = 0x3B9C9C,
dark_cyan = 0x008B8B,
teal_green = 0x00827F,
teal = 0x008080,
teal_blue = 0x007C80,
medium_teal = 0x045F5F,
dark_teal = 0x045D5D,
deep_teal = 0x033E3E,
dark_slate_gray = 0x25383C,
dark_slate_grey = 0x25383C,
gunmetal = 0x2C3539,
blue_moss_green = 0x3C565B,
beetle_green = 0x4C787E,
grayish_turquoise = 0x5E7D7E,
greenish_blue = 0x307D7E,
aquamarine_stone = 0x348781,
sea_turtle_green = 0x438D80,
dull_sea_green = 0x4E8975,
dark_green_blue = 0x1F6357,
deep_sea_green = 0x306754,
bottle_green = 0x006A4E,
elf_green = 0x1B8A6B,
dark_mint = 0x31906E,
jade = 0x00A36C,
earth_green = 0x34A56F,
chrome_green = 0x1AA260,
emerald = 0x50C878,
mint = 0x3EB489,
metallic_green = 0x7C9D8E,
camouflage_green = 0x78866B,
sage_green = 0x848B79,
hazel_green = 0x617C58,
venom_green = 0x728C00,
olive_drab = 0x6B8E23,
olive = 0x808000,
dark_olive_green = 0x556B2F,
military_green = 0x4E5B31,
green_leaves = 0x3A5F0B,
army_green = 0x4B5320,
fern_green = 0x667C26,
fall_forest_green = 0x4E9258,
irish_green = 0x08A04B,
pine_green = 0x387C44,
medium_forest_green = 0x347235,
jungle_green = 0x347C2C,
cactus_green = 0x227442,
dark_green = 0x006400,
deep_green = 0x056608,
deep_emerald_green = 0x046307,
hunter_green = 0x355E3B,
dark_forest_green = 0x254117,
lotus_green = 0x004225,
seaweed_green = 0x437C17,
shamrock_green = 0x347C17,
green_onion = 0x6AA121,
moss_green = 0x8A9A5B,
grass_green = 0x3F9B0B,
green_pepper = 0x4AA02C,
dark_lime_green = 0x41A317,
parrot_green = 0x12AD2B,
clover_green = 0x3EA055,
dinosaur_green = 0x73A16C,
green_snake = 0x6CBB3C,
alien_green = 0x6CC417,
green_apple = 0x4CC417,
lime_green = 0x32CD32,
pea_green = 0x52D017,
kelly_green = 0x4CC552,
zombie_green = 0x54C571,
green_peas = 0x89C35C,
dollar_bill_green = 0x85BB65,
frog_green = 0x99C68E,
turquoise_green = 0xA0D6B4,
dark_sea_green = 0x8FBC8F,
basil_green = 0x829F82,
gray_green = 0xA2AD9C,
iguana_green = 0x9CB071,
citron_green = 0x8FB31D,
acid_green = 0xB0BF1A,
avocado_green = 0xB2C248,
pistachio_green = 0x9DC209,
salad_green = 0xA1C935,
yellow_green = 0x9ACD32,
pastel_green = 0x77DD77,
hummingbird_green = 0x7FE817,
nebula_green = 0x59E817,
stoplight_go_green = 0x57E964,
neon_green = 0x16F529,
jade_green = 0x5EFB6E,
lime_mint_green = 0x36F57F,
spring_green = 0x00FF7F,
medium_spring_green = 0x00FA9A,
emerald_green = 0x5FFB17,
lawn_green = 0x7CFC00,
bright_green = 0x66FF00,
chartreuse = 0x7FFF00,
yellow_lawn_green = 0x87F717,
aloe_vera_green = 0x98F516,
dull_green_yellow = 0xB1FB17,
lemon_green = 0xADF802,
green_yellow = 0xADFF2F,
chameleon_green = 0xBDF516,
neon_yellow_green = 0xDAEE01,
yellow_green_grosbeak = 0xE2F516,
tea_green = 0xCCFB5D,
slime_green = 0xBCE954,
algae_green = 0x64E986,
light_green = 0x90EE90,
dragon_green = 0x6AFB92,
pale_green = 0x98FB98,
mint_green = 0x98FF98,
green_thumb = 0xB5EAAA,
organic_brown = 0xE3F9A6,
light_jade = 0xC3FDB8,
light_mint_green = 0xC2E5D3,
light_rose_green = 0xDBF9DB,
chrome_white = 0xE8F1D4,
honeydew = 0xF0FFF0,
mint_cream = 0xF5FFFA,
lemon_chiffon = 0xFFFACD,
parchment = 0xFFFFC2,
cream = 0xFFFFCC,
cream_white = 0xFFFDD0,
light_goldenrod_yellow = 0xFAFAD2,
light_yellow = 0xFFFFE0,
beige = 0xF5F5DC,
cornsilk = 0xFFF8DC,
blonde = 0xFBF6D9,
champagne = 0xF7E7CE,
antique_white = 0xFAEBD7,
papaya_whip = 0xFFEFD5,
blanched_almond = 0xFFEBCD,
bisque = 0xFFE4C4,
wheat = 0xF5DEB3,
moccasin = 0xFFE4B5,
peach = 0xFFE5B4,
light_orange = 0xFED8B1,
peach_puff = 0xFFDAB9,
coral_peach = 0xFBD5AB,
navajo_white = 0xFFDEAD,
golden_blonde = 0xFBE7A1,
golden_silk = 0xF3E3C3,
dark_blonde = 0xF0E2B6,
light_gold = 0xF1E5AC,
vanilla = 0xF3E5AB,
tan_brown = 0xECE5B6,
dirty_white = 0xE8E4C9,
pale_goldenrod = 0xEEE8AA,
khaki = 0xF0E68C,
cardboard_brown = 0xEDDA74,
harvest_gold = 0xEDE275,
sun_yellow = 0xFFE87C,
corn_yellow = 0xFFF380,
pastel_yellow = 0xFAF884,
neon_yellow = 0xFFFF33,
canary_yellow = 0xFFEF00,
banana_yellow = 0xF5E216,
mustard_yellow = 0xFFDB58,
golden_yellow = 0xFFDF00,
bold_yellow = 0xF9DB24,
rubber_ducky_yellow = 0xFFD801,
gold = 0xFFD700,
bright_gold = 0xFDD017,
chrome_gold = 0xFFCE44,
golden_brown = 0xEAC117,
deep_yellow = 0xF6BE00,
macaroni_and_cheese = 0xF2BB66,
saffron = 0xFBB917,
neon_gold = 0xFDBD01,
beer = 0xFBB117,
yellow_orange = 0xFFAE42,
orange_yellow = 0xFFAE42,
cantaloupe = 0xFFA62F,
cheese_orange = 0xFFA600,
brown_sand = 0xEE9A4D,
sandy_brown = 0xF4A460,
brown_sugar = 0xE2A76F,
camel_brown = 0xC19A6B,
deer_brown = 0xE6BF83,
burly_wood = 0xDEB887,
tan = 0xD2B48C,
light_french_beige = 0xC8AD7F,
sand = 0xC2B280,
sage = 0xBCB88A,
fall_leaf_brown = 0xC8B560,
ginger_brown = 0xC9BE62,
bronze_gold = 0xC9AE5D,
dark_khaki = 0xBDB76B,
olive_green = 0xBAB86C,
brass = 0xB5A642,
cookie_brown = 0xC7A317,
metallic_gold = 0xD4AF37,
bee_yellow = 0xE9AB17,
school_bus_yellow = 0xE8A317,
goldenrod = 0xDAA520,
orange_gold = 0xD4A017,
caramel = 0xC68E17,
cinnamon = 0xC58917,
peru = 0xCD853F,
bronze = 0xCD7F32,
tiger_orange = 0xC88141,
copper = 0xB87333,
dark_gold = 0xAA6C39,
metallic_bronze = 0xA97142,
dark_almond = 0xAB784E,
wood = 0x966F33,
oak_brown = 0x806517,
antique_bronze = 0x665D1E,
hazel = 0x8E7618,
dark_yellow = 0x8B8000,
dark_moccasin = 0x827839,
khaki_green = 0x8A865D,
millennium_jade = 0x93917C,
dark_beige = 0x9F8C76,
bullet_shell = 0xAF9B60,
army_brown = 0x827B60,
sandstone = 0x786D5F,
taupe = 0x483C32,
mocha = 0x493D26,
milk_chocolate = 0x513B1C,
gray_brown = 0x3D3635,
dark_coffee = 0x3B2F2F,
old_burgundy = 0x43302E,
western_charcoal = 0x49413F,
bakers_brown = 0x5C3317,
dark_brown = 0x654321,
sepia_brown = 0x704214,
dark_bronze = 0x804A00,
coffee = 0x6F4E37,
brown_bear = 0x835C3B,
red_dirt = 0x7F5217,
sepia = 0x7F462C,
sienna = 0xA0522D,
saddle_brown = 0x8B4513,
dark_sienna = 0x8A4117,
sangria = 0x7E3817,
blood_red = 0x7E3517,
chestnut = 0x954535,
coral_brown = 0x9E4638,
chestnut_red = 0xC34A2C,
mahogany = 0xC04000,
red_gold = 0xEB5406,
red_fox = 0xC35817,
dark_bisque = 0xB86500,
light_brown = 0xB5651D,
petra_gold = 0xB76734,
copper_red = 0xCB6D51,
orange_salmon = 0xC47451,
chocolate = 0xD2691E,
sedona = 0xCC6600,
papaya_orange = 0xE56717,
halloween_orange = 0xE66C2C,
neon_orange = 0xFF6700,
bright_orange = 0xFF5F1F,
pumpkin_orange = 0xF87217,
carrot_orange = 0xF88017,
dark_orange = 0xFF8C00,
construction_cone_orange = 0xF87431,
indian_saffron = 0xFF7722,
sunrise_orange = 0xE67451,
mango_orange = 0xFF8040,
coral = 0xFF7F50,
basket_ball_orange = 0xF88158,
light_salmon_rose = 0xF9966B,
light_salmon = 0xFFA07A,
dark_salmon = 0xE9967A,
tangerine = 0xE78A61,
light_copper = 0xDA8A67,
salmon_pink = 0xFF8674,
salmon = 0xFA8072,
peach_pink = 0xF98B88,
light_coral = 0xF08080,
pastel_red = 0xF67280,
pink_coral = 0xE77471,
bean_red = 0xF75D59,
valentine_red = 0xE55451,
indian_red = 0xCD5C5C,
tomato = 0xFF6347,
shocking_orange = 0xE55B3C,
orange_red = 0xFF4500,
neon_red = 0xFD1C03,
ruby_red = 0xF62217,
ferrari_red = 0xF70D1A,
fire_engine_red = 0xF62817,
lava_red = 0xE42217,
love_red = 0xE41B17,
grapefruit = 0xDC381F,
cherry_red = 0xC24641,
chilli_pepper = 0xC11B17,
fire_brick = 0xB22222,
tomato_sauce_red = 0xB21807,
carbon_red = 0xA70D2A,
cranberry = 0x9F000F,
saffron_red = 0x931314,
crimson_red = 0x990000,
red_wine = 0x990012,
wine_red = 0x990012,
dark_red = 0x8B0000,
maroon = 0x800000,
burgundy = 0x8C001A,
vermilion = 0x7E191B,
deep_red = 0x800517,
red_blood = 0x660000,
blood_night = 0x551606,
dark_scarlet = 0x560319,
black_bean = 0x3D0C02,
chocolate_brown = 0x3F000F,
midnight = 0x2B1B17,
purple_lily = 0x550A35,
purple_maroon = 0x810541,
plum_pie = 0x7D0541,
plum_velvet = 0x7D0552,
dark_raspberry = 0x872657,
velvet_maroon = 0x7E354D,
rosy_finch = 0x7F4E52,
dull_purple = 0x7F525D,
puce = 0x7F5A58,
rose_dust = 0x997070,
pastel_brown = 0xB1907F,
rosy_pink = 0xB38481,
rosy_brown = 0xBC8F8F,
khaki_rose = 0xC5908E,
lipstick_pink = 0xC48793,
pink_brown = 0xC48189,
old_rose = 0xC08081,
dusty_pink = 0xD58A94,
pink_daisy = 0xE799A3,
rose = 0xE8ADAA,
dusty_rose = 0xC9A9A6,
silver_pink = 0xC4AEAD,
gold_pink = 0xE6C7C2,
rose_gold = 0xECC5C0,
deep_peach = 0xFFCBA4,
pastel_orange = 0xF8B88B,
desert_sand = 0xEDC9AF,
unbleached_silk = 0xFFDDCA,
pig_pink = 0xFDD7E4,
pale_pink = 0xF2D4D7,
blush = 0xFFE6E8,
misty_rose = 0xFFE4E1,
pink_bubble_gum = 0xFFDFDD,
light_rose = 0xFBCFCD,
light_red = 0xFFCCCB,
warm_pink = 0xF6C6BD,
deep_rose = 0xFBBBB9,
light_pink = 0xFFB6C1,
soft_pink = 0xFFB8BF,
donut_pink = 0xFAAFBE,
baby_pink = 0xFAAFBA,
flamingo_pink = 0xF9A7B0,
pastel_pink = 0xFEA3AA,
rose_pink = 0xE7A1B0,
pink_rose = 0xE7A1B0,
cadillac_pink = 0xE38AAE,
carnation_pink = 0xF778A1,
pastel_rose = 0xE5788F,
blush_red = 0xE56E94,
pale_violet_red = 0xDB7093,
purple_pink = 0xD16587,
tulip_pink = 0xC25A7C,
bashful_pink = 0xC25283,
dark_pink = 0xE75480,
dark_hot_pink = 0xF660AB,
hot_pink = 0xFF69B4,
watermelon_pink = 0xFC6C85,
violet_red = 0xF6358A,
hot_deep_pink = 0xF52887,
bright_pink = 0xFF007F,
deep_pink = 0xFF1493,
neon_pink = 0xF535AA,
chrome_pink = 0xFF33AA,
neon_hot_pink = 0xFD349C,
pink_cupcake = 0xE45E9D,
royal_pink = 0xE759AC,
dimorphotheca_magenta = 0xE3319D,
pink_lemonade = 0xE4287C,
red_pink = 0xFA2A55,
crimson = 0xDC143C,
bright_maroon = 0xC32148,
rose_red = 0xC21E56,
rogue_pink = 0xC12869,
burnt_pink = 0xC12267,
pink_violet = 0xCA226B,
magenta_pink = 0xCC338B,
medium_violet_red = 0xC71585,
dark_carnation_pink = 0xC12283,
raspberry_purple = 0xB3446C,
pink_plum = 0xB93B8F,
orchid = 0xDA70D6,
deep_mauve = 0xDF73D4,
violet = 0xEE82EE,
fuchsia_pink = 0xFF77FF,
bright_neon_pink = 0xF433FF,
fuchsia = 0xFF00FF,
crimson_purple = 0xE238EC,
heliotrope_purple = 0xD462FF,
tyrian_purple = 0xC45AEC,
medium_orchid = 0xBA55D3,
purple_flower = 0xA74AC7,
orchid_purple = 0xB048B5,
rich_lilac = 0xB666D2,
pastel_violet = 0xD291BC,
mauve_taupe = 0x915F6D,
viola_purple = 0x7E587E,
eggplant = 0x614051,
plum_purple = 0x583759,
grape = 0x5E5A80,
purple_navy = 0x4E5180,
slate_blue = 0x6A5ACD,
blue_lotus = 0x6960EC,
blurple = 0x5865F2,
light_slate_blue = 0x736AFF,
medium_slate_blue = 0x7B68EE,
periwinkle_purple = 0x7575CF,
very_peri = 0x6667AB,
bright_grape = 0x6F2DA8,
purple_amethyst = 0x6C2DC7,
bright_purple = 0x6A0DAD,
deep_periwinkle = 0x5453A6,
dark_slate_blue = 0x483D8B,
purple_haze = 0x4E387E,
purple_iris = 0x571B7E,
dark_purple = 0x4B0150,
deep_purple = 0x36013F,
midnight_purple = 0x2E1A47,
purple_monster = 0x461B7E,
indigo = 0x4B0082,
blue_whale = 0x342D7E,
rebecca_purple = 0x663399,
purple_jam = 0x6A287E,
dark_magenta = 0x8B008B,
purple = 0x800080,
french_lilac = 0x86608E,
dark_orchid = 0x9932CC,
dark_violet = 0x9400D3,
purple_violet = 0x8D38C9,
jasmine_purple = 0xA23BEC,
purple_daffodil = 0xB041FF,
clematis_violet = 0x842DCE,
blue_violet = 0x8A2BE2,
purple_sage_bush = 0x7A5DC7,
lovely_purple = 0x7F38EC,
neon_purple = 0x9D00FF,
purple_plum = 0x8E35EF,
aztech_purple = 0x893BFF,
medium_purple = 0x9370DB,
light_purple = 0x8467D7,
crocus_purple = 0x9172EC,
purple_mimosa = 0x9E7BFF,
periwinkle = 0xCCCCFF,
pale_lilac = 0xDCD0FF,
lavender_purple = 0x967BB6,
rose_purple = 0xB09FCA,
lilac = 0xC8A2C8,
mauve = 0xE0B0FF,
bright_lilac = 0xD891EF,
purple_dragon = 0xC38EC7,
plum = 0xDDA0DD,
blush_pink = 0xE6A9EC,
pastel_purple = 0xF2A2E8,
blossom_pink = 0xF9B7FF,
wisteria_purple = 0xC6AEC7,
purple_thistle = 0xD2B9D3,
thistle = 0xD8BFD8,
purple_white = 0xDFD3E3,
periwinkle_pink = 0xE9CFEC,
cotton_candy = 0xFCDFFF,
lavender_pinocchio = 0xEBDDE2,
dark_white = 0xE1D9D1,
ash_white = 0xE9E4D4,
white_chocolate = 0xEDE6D6,
soft_ivory = 0xFAF0DD,
off_white = 0xF8F0E3,
pearl_white = 0xF8F6F0,
red_white = 0xF3E8EA,
lavender_blush = 0xFFF0F5,
pearl = 0xFDEEF4,
egg_shell = 0xFFF9E3,
old_lace = 0xFEF0E3,
linen = 0xFAF0E6,
sea_shell = 0xFFF5EE,
bone_white = 0xF9F6EE,
rice = 0xFAF5EF,
floral_white = 0xFFFAF0,
ivory = 0xFFFFF0,
white_gold = 0xFFFFF4,
light_white = 0xFFFFF7,
white_smoke = 0xF5F5F5,
cotton = 0xFBFBF9,
snow = 0xFFFAFA,
milk_white = 0xFEFCFF,
half_white = 0xFFFEFA;
};
/**
* @brief predefined color constants, same as colors
*/
namespace colours = colors;
};

View File

@ -34,12 +34,14 @@
#include <mutex>
#include <shared_mutex>
using json = nlohmann::json;
#define DISCORD_API_VERSION "10"
#define API_PATH "/api/v" DISCORD_API_VERSION
namespace dpp {
using json = nlohmann::json;
// Forward declarations
class cluster;
@ -358,7 +360,7 @@ public:
/**
* @brief List of voice channels we are connecting to keyed by guild id
*/
std::unordered_map<snowflake, voiceconn*> connecting_voice_channels;
std::unordered_map<snowflake, std::unique_ptr<voiceconn>> connecting_voice_channels;
/**
* @brief The gateway address we reconnect to when we resume a session

View File

@ -48,7 +48,7 @@
#include <functional>
#include <chrono>
using json = nlohmann::json;
struct OpusDecoder;
struct OpusEncoder;
@ -56,6 +56,8 @@ struct OpusRepacketizer;
namespace dpp {
using json = nlohmann::json;
// Forward declaration
class cluster;
@ -403,6 +405,7 @@ class DPP_EXPORT discord_voice_client : public websocket_client
* @brief Called by ssl_client when there is data to be
* read. At this point we insert that data into the
* input queue.
* @throw dpp::voice_exception if voice support is not compiled into D++
*/
void read_ready();

View File

@ -40,6 +40,7 @@
#include <dpp/scheduled_event.h>
#include <dpp/stage_instance.h>
#include <dpp/integration.h>
#include <dpp/auditlog.h>
#include <functional>
#include <variant>
#include <exception>
@ -473,17 +474,6 @@ struct DPP_EXPORT interaction_create_t : public event_dispatch_t {
*/
void delete_original_response(command_completion_event_t callback = utility::log_error()) const;
/**
* @brief Get a command line parameter
*
* @note Doesn't work on subcommands. If you want to get a parameter from a subcommand, you have to loop through the options by yourself.
*
* @param name The command line parameter to retrieve
* @return const command_value& If the command line parameter does not
* exist, an empty variant is returned.
*/
const virtual command_value& get_parameter(const std::string& name) const;
/**
* @brief command interaction
*/
@ -493,13 +483,24 @@ struct DPP_EXPORT interaction_create_t : public event_dispatch_t {
* @brief Destroy this object
*/
virtual ~interaction_create_t() = default;
/**
* @brief Get a slashcommand parameter
*
* @param name The name of the command line parameter to retrieve the value for
* @return command_value Returns the value of the first option that matches the given name.
* If no matches are found, an empty variant is returned.
*
* @throw dpp::logic_exception if the interaction is not for a command
*/
virtual command_value get_parameter(const std::string& name) const;
};
/**
* @brief User has issued a slash command
*/
struct DPP_EXPORT slashcommand_t : public interaction_create_t {
public:
/** Constructor
* @param client The shard the event originated on
* @param raw Raw event text as JSON
@ -514,6 +515,7 @@ struct DPP_EXPORT button_click_t : public interaction_create_t {
private:
using interaction_create_t::get_parameter;
public:
/** Constructor
* @param client The shard the event originated on
* @param raw Raw event text as JSON
@ -534,6 +536,7 @@ struct DPP_EXPORT form_submit_t : public interaction_create_t {
private:
using interaction_create_t::get_parameter;
public:
/** Constructor
* @param client The shard the event originated on
* @param raw Raw event text as JSON
@ -585,7 +588,10 @@ public:
* user or message.
*/
struct DPP_EXPORT context_menu_t : public interaction_create_t {
private:
using interaction_create_t::get_parameter;
public:
/** Constructor
* @param client The shard the event originated on
* @param raw Raw event text as JSON
@ -910,7 +916,12 @@ struct DPP_EXPORT message_reaction_add_t : public event_dispatch_t {
*/
guild_member reacting_member;
/**
* @brief channel the reaction happened on
* @brief Channel ID the reaction happened on
*/
snowflake channel_id;
/**
* @brief channel the reaction happened on (Optional)
* @note only filled when the channel is cached
*/
channel* reacting_channel;
/**
@ -956,7 +967,12 @@ struct DPP_EXPORT message_reaction_remove_t : public event_dispatch_t {
*/
dpp::snowflake reacting_user_id;
/**
* @brief channel the reaction happened on
* @brief Channel ID the reaction was removed in
*/
snowflake channel_id;
/**
* @brief channel the reaction happened on (optional)
* @note only filled when the channel is cached
*/
channel* reacting_channel;
/**
@ -1034,7 +1050,12 @@ struct DPP_EXPORT message_reaction_remove_emoji_t : public event_dispatch_t {
*/
guild* reacting_guild;
/**
* @brief channel the reaction happened on
* @brief Channel ID the reactions was removed in
*/
snowflake channel_id;
/**
* @brief channel the reaction happened on (optional)
* @note only filled when the channel is cached
*/
channel* reacting_channel;
/**
@ -1143,7 +1164,12 @@ struct DPP_EXPORT message_reaction_remove_all_t : public event_dispatch_t {
*/
guild* reacting_guild;
/**
* @brief channel the reaction happened on
* @brief Channel ID the reactions was removed in
*/
snowflake channel_id;
/**
* @brief channel the reaction happened on (optional)
* @note only filled when the channel is cached
*/
channel* reacting_channel;
/**
@ -1395,6 +1421,19 @@ struct DPP_EXPORT message_create_t : public event_dispatch_t {
void reply(message&& msg, bool mention_replied_user = false, command_completion_event_t callback = utility::log_error()) const;
};
/** @brief Guild audit log entry create */
struct DPP_EXPORT guild_audit_log_entry_create_t : public event_dispatch_t {
/** Constructor
* @param client The shard the event originated on
* @param raw Raw event text as JSON
*/
guild_audit_log_entry_create_t(class discord_client* client, const std::string& raw);
/**
* @brief created audit log entry
*/
audit_entry entry;
};
/** @brief Guild ban add */
struct DPP_EXPORT guild_ban_add_t : public event_dispatch_t {
/** Constructor

View File

@ -167,6 +167,19 @@ public:
* @return std::string mention
*/
std::string get_mention() const;
/**
* @brief Get the custom emoji url
*
* @param size The size of the emoji in pixels. It can be any power of two between 16 and 4096,
* otherwise the default sized emoji is returned.
* @param format The format to use for the emoji. It can be one of `i_webp`, `i_jpg`, `i_png` or `i_gif`.
* When passing `i_gif`, it returns an empty string for non-animated emojis. Consider using the `prefer_animated` parameter instead.
* @param prefer_animated Whether you prefer gif format.
* If true, it'll return gif format whenever the emoji is available as animated.
* @return std::string emoji url or an empty string, if the id is not set
*/
std::string get_url(uint16_t size = 0, const image_type format = i_png, bool prefer_animated = true) const;
};
/**

View File

@ -148,4 +148,7 @@ event_decl(automod_rule_update, AUTO_MODERATION_RULE_UPDATE);
event_decl(automod_rule_delete, AUTO_MODERATION_RULE_DELETE);
event_decl(automod_rule_execute, AUTO_MODERATION_ACTION_EXECUTION);
/* Audit log */
event_decl(guild_audit_log_entry_create, GUILD_AUDIT_LOG_ENTRY_CREATE);
}};

View File

@ -135,40 +135,50 @@ enum guild_flags : uint32_t {
/**
* @brief Additional boolean flag values for guild, as guild_flags is full
*/
enum guild_flags_extra : uint8_t {
enum guild_flags_extra : uint16_t {
/** Guild has premium progress bar enabled */
g_premium_progress_bar_enabled = 0b00000001,
g_premium_progress_bar_enabled = 0b0000000000000001,
/** Guild can have an animated banner (doesn't mean it actually has one though) */
g_animated_banner = 0b00000010,
g_animated_banner = 0b0000000000000010,
/** Guild has auto moderation */
g_auto_moderation = 0b00000100,
g_auto_moderation = 0b0000000000000100,
/** Guild has paused invites, preventing new users from joining */
g_invites_disabled = 0b00001000,
g_invites_disabled = 0b0000000000001000,
/** Guild has been set as support server of an app in the App Directory */
g_developer_support_server = 0b00010000,
g_developer_support_server = 0b0000000000010000,
/** Guild role subscription purchase and renewal notifications are off */
g_no_role_subscription_notifications = 0b00100000,
g_no_role_subscription_notifications = 0b0000000000100000,
/** Guild role subscription sticker reply buttons are off */
g_no_role_subscription_notification_replies = 0b01000000,
g_no_role_subscription_notification_replies = 0b0000000001000000,
/** Guild has role subscriptions that can be purchased */
g_role_subscriptions_available_for_purchase = 0b10000000,
g_role_subscriptions_available_for_purchase = 0b0000000010000000,
/** Guild has disabled alerts for join raids in the configured safety alerts channel */
g_raid_alerts_disabled = 0b0000000100000000,
};
/**
* @brief Various flags that can be used to indicate the status of a guild member.
* @note Use set_mute and set_deaf member functions and do not toggle the bits yourself.
* @note Use the setter functions in dpp::guild_member and do not toggle the bits yourself.
*/
enum guild_member_flags : uint8_t {
enum guild_member_flags : uint16_t {
/** Member deafened in voice channels */
gm_deaf = 0b00000001,
gm_deaf = 0b0000000000000001,
/** Member muted in voice channels */
gm_mute = 0b00000010,
gm_mute = 0b0000000000000010,
/** Member pending verification by membership screening */
gm_pending = 0b00000100,
gm_pending = 0b0000000000000100,
/** Member has animated guild-specific avatar */
gm_animated_avatar = 0b00001000,
gm_animated_avatar = 0b0000000000001000,
/** gm_deaf or gm_mute has been toggled */
gm_voice_action = 0b00010000,
gm_voice_action = 0b0000000000010000,
/** Member has left and rejoined the guild */
gm_did_rejoin = 0b0000000000100000,
/** Member has completed onboarding */
gm_completed_onboarding = 0b0000000001000000,
/** Member is exempt from guild verification requirements */
gm_bypasses_verification = 0b0000000010000000,
/** Member has started onboarding */
gm_started_onboarding = 0b0000000100000000,
};
/**
@ -194,7 +204,7 @@ public:
/** Boosting since */
time_t premium_since;
/** A set of flags built from the bitmask defined by dpp::guild_member_flags */
uint8_t flags;
uint16_t flags;
/** Default constructor */
guild_member();
@ -247,6 +257,38 @@ public:
*/
bool is_pending() const;
/**
* @brief Returns true if the user has left and rejoined the guild
*
* @return true user has left and rejoined the guild
* @return false user has not rejoined
*/
bool has_rejoined() const;
/**
* @brief Returns true if the user has completed onboarding
*
* @return true user has completed onboarding
* @return false user has not completed onboarding
*/
bool has_completed_onboarding() const;
/**
* @brief Returns true if the user has started onboarding
*
* @return true user has started onboarding
* @return false user has not started onboarding yet
*/
bool has_started_onboarding() const;
/**
* @brief Returns true if the user is exempt from guild verification requirements
*
* @return true user bypasses verification
* @return false user doesn't bypass verification
*/
bool has_bypasses_verification() const;
/**
* @brief Returns true if the user's per-guild custom avatar is animated
*
@ -263,7 +305,7 @@ public:
* @param size The size of the avatar in pixels. It can be any power of two between 16 and 4096,
* otherwise the default sized avatar is returned.
* @param format The format to use for the avatar. It can be one of `i_webp`, `i_jpg`, `i_png` or `i_gif`.
* Passing `i_gif` might result in an invalid url for non-animated images. Consider using the `prefer_animated` parameter instead.
* When passing `i_gif`, it returns an empty string for non-animated images. Consider using the `prefer_animated` parameter instead.
* @param prefer_animated Whether you prefer gif format.
* If true, it'll return gif format whenever the image is available as animated.
* @return std::string avatar url or an empty string, if required attributes are missing or an invalid format was passed
@ -280,10 +322,8 @@ public:
guild_member& set_nickname(const std::string& nick);
/**
* @brief Get the dpp::user object for this member
* @return dpp::user user object. If not in cache, it returns nullptr
*
*
* @brief Find the dpp::user object for this member. This is an alias for dpp::find_user
* @return dpp::user* Pointer to the user object. If not in cache, it returns nullptr
*/
user* get_user() const;
@ -295,6 +335,15 @@ public:
bool operator == (guild_member const& other_member) const;
/**
* @brief Set whether the user is exempt from guild verification requirements
*
* @param is_bypassing_verification value to set
*
* @return guild_member& reference to self
*/
guild_member& set_bypasses_verification(const bool is_bypassing_verification);
/**
* @brief Set whether the user is muted in voice channels
*
@ -538,6 +587,9 @@ public:
/** Snowflake ID of widget channel, or 0 */
snowflake widget_channel_id;
/** The id of the channel where admins and moderators of Community guilds receive safety alerts from Discord */
snowflake safety_alerts_channel_id;
/** Approximate member count. May be sent as zero */
uint32_t member_count;
@ -555,6 +607,11 @@ public:
*/
uint32_t max_members;
/**
* @brief Additional flags (values from dpp::guild_flags_extra)
*/
uint16_t flags_extra;
/** Shard ID of the guild */
uint16_t shard_id;
@ -587,11 +644,6 @@ public:
*/
guild_nsfw_level_t nsfw_level;
/**
* @brief Additional flags
*/
uint8_t flags_extra;
/** Default constructor, zeroes all values */
guild();
@ -720,7 +772,7 @@ public:
* @param size The size of the icon in pixels. It can be any power of two between 16 and 4096,
* otherwise the default sized icon is returned.
* @param format The format to use for the avatar. It can be one of `i_webp`, `i_jpg`, `i_png` or `i_gif`.
* Passing `i_gif` might result in an invalid url for non-animated images. Consider using the `prefer_animated` parameter instead.
* When passing `i_gif`, it returns an empty string for non-animated images. Consider using the `prefer_animated` parameter instead.
* @param prefer_animated Whether you prefer gif format.
* If true, it'll return gif format whenever the image is available as animated.
* @return std::string icon url or an empty string, if required attributes are missing or an invalid format was passed
@ -848,6 +900,12 @@ public:
*/
bool has_role_subscriptions_available_for_purchase() const;
/**
* @brief Guild has disabled alerts for join raids in the configured safety alerts channel
* @return bool dpp::g_raid_alerts_disabled flag is set
*/
bool has_raid_alerts_disabled() const;
/**
* @brief Guild has access to set an animated guild icon
* @return bool can have animated icon

View File

@ -22,6 +22,7 @@
#include <dpp/export.h>
#include <string>
#include <map>
#include <list>
#include <vector>
#include <variant>
#include <dpp/sslclient.h>
@ -189,7 +190,7 @@ class DPP_EXPORT https_client : public ssl_client
* @brief Headers from the server's response, e.g. RateLimit
* headers, cookies, etc.
*/
std::map<std::string, std::string> response_headers;
std::multimap<std::string, std::string> response_headers;
/**
* @brief Handle input buffer
@ -247,9 +248,10 @@ public:
* @param json The json content
* @param filenames File names of files to send
* @param contents Contents of each of the files to send
* @param mimetypes MIME types of each of the files to send
* @return multipart mime content and headers
*/
static multipart_content build_multipart(const std::string &json, const std::vector<std::string>& filenames = {}, const std::vector<std::string>& contents = {});
static multipart_content build_multipart(const std::string &json, const std::vector<std::string>& filenames = {}, const std::vector<std::string>& contents = {}, const std::vector<std::string>& mimetypes = {});
/**
* @brief Processes incoming data from the SSL socket input buffer.
@ -272,16 +274,36 @@ public:
* @brief Get a HTTP response header
*
* @param header_name Header name to find, case insensitive
* @return Header content or empty string if not found
* @return Header content or empty string if not found.
* If multiple values have the same header_name, this will return one of them.
* @see get_header_count to determine if multiple are present
* @see get_header_list to retrieve all entries of the same header_name
*/
const std::string get_header(std::string header_name) const;
/**
* @brief Get the number of headers with the same header name
*
* @param header_name
* @return the number of headers with this count
*/
size_t get_header_count(std::string header_name) const;
/**
* @brief Get a set of HTTP response headers with a common name
*
* @param header_name
* @return A list of headers with the same name, or an empty list if not found
*/
const std::list<std::string> get_header_list(std::string header_name) const;
/**
* @brief Get all HTTP response headers
*
* @return headers as a map
*/
const std::map<std::string, std::string> get_headers() const;
const std::multimap<std::string, std::string> get_headers() const;
/**
* @brief Get the response content
@ -313,4 +335,4 @@ public:
};
};
};

View File

@ -37,7 +37,9 @@ enum integration_type {
/// YouTube integration
i_youtube,
/// Discord integration
i_discord
i_discord,
/// Subscription
i_guild_subscription,
};
/**

View File

@ -37,50 +37,54 @@ public:
*/
std::string code;
/** Readonly expiration timestamp of this invite or 0 if the invite doesn't expire
* @note Only returned from cluster::invite_get
*/
time_t expires_at;
/** Guild for the invite
/** Guild ID this invite is for
*/
snowflake guild_id;
/** Channel id for invite
/** Channel ID this invite is for
*/
snowflake channel_id;
/** User ID of invite creator
/** User ID who created this invite
*/
snowflake inviter_id;
/** Target user ID of invite, for invites sent via DM
/** The user ID whose stream to display for this voice channel stream invite
*/
snowflake target_user_id;
/** Target user type (generally this is always 1, "stream")
/** Target type
*/
uint8_t target_user_type;
uint8_t target_type;
/** Approximate number of online users
* @note Only returned from cluster::invite_get
*/
uint32_t approximate_presence_count;
/** Approximate total users online and offline
/** Approximate number of total users online and offline
* @note Only returned from cluster::invite_get
*/
uint32_t approximate_member_count;
/** Maximum age (in seconds) of invite
/** Duration (in seconds) after which the invite expires, or 0 for no expiration. Must be between 0 and 604800 (7 days). Defaults to 86400 (1 day)
*/
uint32_t max_age;
/** Maximum number of uses
/** Maximum number of uses, or 0 for unlimited. Must be between 0 and 100. Defaults to 0
*/
uint32_t max_uses;
/** True if a temporary invite which grants access for a limited time
/** Whether this invite only grants temporary membership
*/
bool temporary;
/** True if this invite should not replace or "attach to" similar invites
*/
bool unique;
/** How many times this invite has been used
*
* @note Only set when using cluster::channel_invites_get
*/
uint32_t uses;
/** The stage instance data if there is a public stage instance in the stage channel this invite is for
* @deprecated Deprecated
*/
stage_instance stage;
/** Timestamp at which the invite was created
*/
time_t created_at;
/** Constructor
*/

View File

@ -523,7 +523,7 @@ public:
struct DPP_EXPORT embed_footer {
/** Footer text */
std::string text;
/** Footer icon url */
/** Footer icon url (only supports http(s) and attachments) */
std::string icon_url;
/** Proxied icon url */
std::string proxy_url;
@ -577,9 +577,9 @@ struct DPP_EXPORT embed_provider {
struct DPP_EXPORT embed_author {
/** Author name */
std::string name;
/** Author url */
/** Author url (only supports http(s)) */
std::string url;
/** Author icon url */
/** Author icon url (only supports http(s) and attachments) */
std::string icon_url;
/** Proxied icon url */
std::string proxy_icon_url;
@ -589,9 +589,9 @@ struct DPP_EXPORT embed_author {
* @brief A dpp::embed may contain zero or more fields
*/
struct DPP_EXPORT embed_field {
/** Name of field */
/** Name of field (max length 256) */
std::string name;
/** Value of field (max length 1000) */
/** Value of field (max length 1024) */
std::string value;
/** True if the field is to be displayed inline */
bool is_inline;
@ -659,7 +659,7 @@ struct DPP_EXPORT embed {
/** Set the footer of the embed. Returns the embed itself so these method calls may be "chained"
* @param text string to set as footer text. It will be truncated to the maximum length of 2048 UTF-8 characters.
* @param icon_url an url to set as footer icon url
* @param icon_url an url to set as footer icon url (only supports http(s) and attachments)
* @return A reference to self
*/
embed& set_footer(const std::string& text, const std::string& icon_url);
@ -698,8 +698,8 @@ struct DPP_EXPORT embed {
/** Set embed author. Returns the embed itself so these method calls may be "chained"
* @param name The name of the author. It will be truncated to the maximum length of 256 UTF-8 characters.
* @param url The url of the author
* @param icon_url The icon URL of the author
* @param url The url of the author (only supports http(s))
* @param icon_url The icon URL of the author (only supports http(s) and attachments)
* @return A reference to self
*/
embed& set_author(const std::string& name, const std::string& url, const std::string& icon_url);
@ -712,7 +712,7 @@ struct DPP_EXPORT embed {
embed& set_provider(const std::string& name, const std::string& url);
/** Set embed image. Returns the embed itself so these method calls may be "chained"
* @param url The embed image URL
* @param url The embed image URL (only supports http(s) and attachments)
* @return A reference to self
*/
embed& set_image(const std::string& url);
@ -724,7 +724,7 @@ struct DPP_EXPORT embed {
embed& set_video(const std::string& url);
/** Set embed thumbnail. Returns the embed itself so these method calls may be "chained"
* @param url The embed thumbnail url
* @param url The embed thumbnail url (only supports http(s) and attachments)
* @return A reference to self
*/
embed& set_thumbnail(const std::string& url);
@ -784,6 +784,10 @@ struct DPP_EXPORT attachment {
std::string content_type;
/** Whether this attachment is ephemeral, if applicable */
bool ephemeral;
/** The duration of the audio file (currently for voice messages) */
double duration_secs;
/** base64 encoded bytearray representing a sampled waveform (currently for voice messages) */
std::string waveform;
/** Owning message */
struct message* owner;
@ -981,6 +985,8 @@ enum message_flags : uint16_t {
m_thread_mention_failed = 1 << 8,
/// this message will not trigger push and desktop notifications
m_suppress_notifications = 1 << 12,
/// this message is a voice message
m_is_voice_message = 1 << 13,
};
/**
@ -1183,6 +1189,9 @@ struct DPP_EXPORT message : public managed {
/** File content to upload (raw binary) */
std::vector<std::string> filecontent;
/** Mime type of files to upload */
std::vector<std::string> filemimetype;
/**
* @brief Reference to another message, e.g. a reply
*/
@ -1411,6 +1420,13 @@ struct DPP_EXPORT message : public managed {
*/
bool suppress_notifications() const;
/**
* @brief True if the message is a voice message
*
* @return True if voice message
*/
bool is_voice_message() const;
/**
* @brief Add a component (button) to message
*
@ -1466,9 +1482,10 @@ struct DPP_EXPORT message : public managed {
*
* @param filename filename
* @param filecontent raw file content contained in std::string
* @param filemimetype optional mime type of the file
* @return message& reference to self
*/
message& add_file(const std::string &filename, const std::string &filecontent);
message& add_file(const std::string &filename, const std::string &filecontent, const std::string &filemimetype = "");
/**
* @brief Set the message content

View File

@ -71,6 +71,9 @@ enum permissions : uint64_t {
p_send_messages_in_threads = 0x04000000000, //!< allows for sending messages in threads
p_use_embedded_activities = 0x08000000000, //!< allows for using activities (applications with the EMBEDDED flag) in a voice channel
p_moderate_members = 0x10000000000, //!< allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels
p_view_creator_monetization_analytics = 0x20000000000, //!< allows for viewing role subscription insights
p_use_soundboard = 0x40000000000, //!< allows for using soundboard in a voice channel
p_send_voice_messages = 0x0000400000000000, //!< allows sending voice messages
};
/**
@ -80,38 +83,42 @@ enum permissions : uint64_t {
using role_permissions = permissions;
/**
* @brief Represents a permission bitmask (refer to enum dpp::permissions) which are hold in an uint64_t
* @brief Represents a permission bitmask (refer to enum dpp::permissions) which are held in an uint64_t
*/
class DPP_EXPORT permission {
protected:
/**
* @brief The permission bitmask value
*/
uint64_t value;
uint64_t value{0};
public:
/**
* @brief Construct a permission object
* @param value A permission bitmask
* @brief Default constructor, initializes permission to 0
*/
permission(const uint64_t& value);
constexpr permission() = default;
/**
* @brief Construct a permission object
*/
permission();
* @brief Bitmask constructor, initializes permission to the argument
* @param value The bitmask to initialize the permission to
*/
constexpr permission(uint64_t value) noexcept : value{value} {}
/**
* @brief For acting like an integer
* @return The permission bitmask value
*/
operator uint64_t() const;
constexpr operator uint64_t() const noexcept {
return value;
}
/**
* @brief For acting like an integer
* @return A reference to the permission bitmask value
*/
operator uint64_t &();
constexpr operator uint64_t &() noexcept {
return value;
}
/**
* @brief For building json
@ -134,7 +141,7 @@ public:
* @return bool True if it has all the given permissions
*/
template <typename... T>
bool has(T... values) const {
constexpr bool has(T... values) const noexcept {
return (value & (0 | ... | values)) == (0 | ... | values);
}
@ -153,8 +160,8 @@ public:
* @return permission& reference to self for chaining
*/
template <typename... T>
typename std::enable_if<(std::is_convertible<T, uint64_t>::value && ...), permission&>::type
add(T... values) {
std::enable_if_t<(std::is_convertible_v<T, uint64_t> && ...), permission&>
constexpr add(T... values) noexcept {
value |= (0 | ... | values);
return *this;
}
@ -173,8 +180,8 @@ public:
* @return permission& reference to self for chaining
*/
template <typename... T>
typename std::enable_if<(std::is_convertible<T, uint64_t>::value && ...), permission&>::type
set(T... values) {
std::enable_if_t<(std::is_convertible_v<T, uint64_t> && ...), permission&>
constexpr set(T... values) noexcept {
value = (0 | ... | values);
return *this;
}
@ -194,8 +201,8 @@ public:
* @return permission& reference to self for chaining
*/
template <typename... T>
typename std::enable_if<(std::is_convertible<T, uint64_t>::value && ...), permission&>::type
remove(T... values) {
std::enable_if_t<(std::is_convertible_v<T, uint64_t> && ...), permission&>
constexpr remove(T... values) noexcept {
value &= ~(0 | ... | values);
return *this;
}

View File

@ -69,7 +69,9 @@ enum presence_status : uint8_t {
/// DND
ps_dnd = 2,
/// Idle
ps_idle = 3
ps_idle = 3,
/// Invisible (show as offline)
ps_invisible = 4,
};
/**

View File

@ -70,7 +70,7 @@ enum http_error {
*/
struct DPP_EXPORT http_request_completion_t {
/** @brief HTTP headers of response */
std::map<std::string, std::string> headers;
std::multimap<std::string, std::string> headers;
/** @brief HTTP status, e.g. 200 = OK, 404 = Not found, 429 = Rate limited */
uint16_t status = 0;
/** @brief Error status (e.g. if the request could not connect at all) */
@ -149,6 +149,8 @@ public:
std::vector<std::string> file_name;
/** @brief Upload file contents (binary) */
std::vector<std::string> file_content;
/** @brief Upload file mime types (application/octet-stream if unspecified) */
std::vector<std::string> file_mimetypes;
/** @brief Request mime type */
std::string mimetype;
/** @brief Request headers (non-discord requests only) */
@ -166,8 +168,9 @@ public:
* @param audit_reason Audit log reason to send, empty to send none
* @param filename The filename (server side) of any uploaded file
* @param filecontent The binary content of any uploaded file for the request
* @param filemimetype The MIME type of any uploaded file for the request
*/
http_request(const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata = "", http_method method = m_get, const std::string &audit_reason = "", const std::string &filename = "", const std::string &filecontent = "");
http_request(const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata = "", http_method method = m_get, const std::string &audit_reason = "", const std::string &filename = "", const std::string &filecontent = "", const std::string &filemimetype = "");
/**
* @brief Constructor. When constructing one of these objects it should be passed to request_queue::post_request().
@ -179,8 +182,9 @@ public:
* @param audit_reason Audit log reason to send, empty to send none
* @param filename The filename (server side) of any uploaded file
* @param filecontent The binary content of any uploaded file for the request
* @param filemimetypes The MIME type of any uploaded file for the request
*/
http_request(const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata = "", http_method method = m_get, const std::string &audit_reason = "", const std::vector<std::string> &filename = {}, const std::vector<std::string> &filecontent = {});
http_request(const std::string &_endpoint, const std::string &_parameters, http_completion_event completion, const std::string &_postdata = "", http_method method = m_get, const std::string &audit_reason = "", const std::vector<std::string> &filename = {}, const std::vector<std::string> &filecontent = {}, const std::vector<std::string> &filemimetypes = {});
/**
* @brief Constructor. When constructing one of these objects it should be passed to request_queue::post_request().

View File

@ -132,7 +132,7 @@ template<class T> inline void rest_request_list(dpp::cluster* c, const char* bas
*/
template<> inline void rest_request_list<invite>(dpp::cluster* c, const char* basepath, const std::string &major, const std::string &minor, http_method method, const std::string& postdata, command_completion_event_t callback, const std::string& key) {
c->post_rest(basepath, major, minor, method, postdata, [c, callback](json &j, const http_request_completion_t& http) {
std::unordered_map<std::string, invite> list;
invite_map list;
confirmation_callback_t e(c, confirmation(), http);
if (!e.is_error()) {
for (auto & curr_item : j) {
@ -160,7 +160,7 @@ template<> inline void rest_request_list<invite>(dpp::cluster* c, const char* ba
*/
template<> inline void rest_request_list<voiceregion>(dpp::cluster* c, const char* basepath, const std::string &major, const std::string &minor, http_method method, const std::string& postdata, command_completion_event_t callback, const std::string& key) {
c->post_rest(basepath, major, minor, method, postdata, [c, callback](json &j, const http_request_completion_t& http) {
std::unordered_map<std::string, voiceregion> list;
voiceregion_map list;
confirmation_callback_t e(c, confirmation(), http);
if (!e.is_error()) {
for (auto & curr_item : j) {
@ -172,9 +172,38 @@ template<> inline void rest_request_list<voiceregion>(dpp::cluster* c, const cha
}
});
}
/**
* @brief Templated REST request helper to save on typing (for returned lists, specialised for bans)
*
* @tparam T singular type to return in lambda callback
* @tparam T map type to return in lambda callback
* @param c calling cluster
* @param basepath base path for API call
* @param major major API function
* @param minor minor API function
* @param method HTTP method
* @param postdata Post data or empty string
* @param key Key name of elements in the json list
* @param callback Callback lambda
*/
template<> inline void rest_request_list<ban>(dpp::cluster* c, const char* basepath, const std::string &major, const std::string &minor, http_method method, const std::string& postdata, command_completion_event_t callback, const std::string& key) {
c->post_rest(basepath, major, minor, method, postdata, [c, callback](json &j, const http_request_completion_t& http) {
std::unordered_map<snowflake, ban> list;
confirmation_callback_t e(c, confirmation(), http);
if (!e.is_error()) {
for (auto & curr_item : j) {
ban curr_ban = ban().fill_from_json(&curr_item);
list[curr_ban.user_id] = curr_ban;
}
}
if (callback) {
callback(confirmation_callback_t(c, list, http));
}
});
}
/**
* @brief Templated REST request helper to save on typing (for returned vectors)
* @brief Templated REST request helper to save on typing (for returned lists, specialised for objects which doesn't have ids)
*
* @tparam T singular type to return in lambda callback
* @tparam T vector type to return in lambda callback

View File

@ -132,6 +132,7 @@ struct DPP_EXPORT confirmation {
*
*/
typedef std::variant<
active_threads,
application_role_connection,
application_role_connection_metadata_list,
confirmation,

View File

@ -31,10 +31,12 @@ namespace dpp {
/** Various flags related to dpp::role */
enum role_flags : uint8_t {
r_hoist = 0b00000001, //!< Hoisted role
r_hoist = 0b00000001, //!< Hoisted role (if the role is pinned in the user listing)
r_managed = 0b00000010, //!< Managed role (introduced by a bot or application)
r_mentionable = 0b00000100, //!< Mentionable with a ping
r_premium_subscriber = 0b00001000, //!< This is set for the role given to nitro
r_mentionable = 0b00000100, //!< Whether this role is mentionable with a ping
r_premium_subscriber = 0b00001000, //!< Whether this is the guild's booster role
r_available_for_purchase = 0b00010000, //!< Whether the role is available for purchase
r_guild_connections = 0b00100000, //!< Whether the role is a guild's linked role
};
/**
@ -72,6 +74,8 @@ public:
snowflake integration_id;
/** Bot id if any (e.g. role is a bot's role created when it was invited) */
snowflake bot_id;
/** The id of the role's subscription sku and listing */
snowflake subscription_listing_id;
/** The unicode emoji used for the role's icon, can be an empty string */
std::string unicode_emoji;
/** The role icon hash, can be an empty string */
@ -268,6 +272,21 @@ public:
* @return bool True if the role is managed (introduced for a bot or other application by Discord)
*/
bool is_managed() const;
/**
* @brief True if the role is the guild's Booster role
* @return bool whether the role is the premium subscriber, AKA "boost", role for the guild
*/
bool is_premium_subscriber() const;
/**
* @brief True if the role is available for purchase
* @return bool whether this role is available for purchase
*/
bool is_available_for_purchase() const;
/**
* @brief True if the role is a linked role
* @return bool True if the role is a linked role
*/
bool is_linked() const;
/**
* @brief True if has create instant invite permission
* @note Having the administrator permission causes this method to always return true
@ -550,6 +569,27 @@ public:
* @return bool True if user has the moderate users permission or is administrator.
*/
bool has_moderate_members() const;
/**
* @brief True if has the view creator monetization analytics permission.
* @note Having the administrator permission causes this method to always return true
* Channel specific overrides may apply to permissions.
* @return bool True if user has the view creator monetization analytics permission or is administrator.
*/
bool has_view_creator_monetization_analytics() const;
/**
* @brief True if has the use soundboard permission.
* @note Having the administrator permission causes this method to always return true
* Channel specific overrides may apply to permissions.
* @return bool True if user has the use soundboard permission or is administrator.
*/
bool has_use_soundboard() const;
/**
* @brief True if has the send voice messages permission.
* @note Having the administrator permission causes this method to always return true
* Channel specific overrides may apply to permissions.
* @return bool True if user has the send voice messages permission or is administrator.
*/
bool has_send_voice_messages() const;
/**
* @brief Get guild members who have this role

View File

@ -62,7 +62,7 @@ public:
/**
* @brief Construct a snowflake object
* @param value A snowflake value
* @param string_value A snowflake value
*/
snowflake(const std::string& string_value);

View File

@ -24,6 +24,7 @@
#include <string>
#include <functional>
#include <dpp/socket.h>
#include <cstdint>
namespace dpp {

View File

@ -165,7 +165,7 @@ template <uint64_t> uint64_t from_string(const std::string &s)
*/
template <uint32_t> uint32_t from_string(const std::string &s)
{
return std::stoul(s, 0, 10);
return (uint32_t) std::stoul(s, 0, 10);
}
/**
@ -205,7 +205,7 @@ template <typename T> std::string to_hex(T i)
template <typename T> std::string leading_zeroes(T i, size_t width)
{
std::stringstream stream;
stream << std::setfill('0') << std::setw(width) << std::dec << i;
stream << std::setfill('0') << std::setw((int)width) << std::dec << i;
return stream.str();
}

View File

@ -140,7 +140,7 @@ public:
* @param size The size of the avatar in pixels. It can be any power of two between 16 and 4096,
* otherwise the default sized avatar is returned.
* @param format The format to use for the avatar. It can be one of `i_webp`, `i_jpg`, `i_png` or `i_gif`.
* Passing `i_gif` might result in an invalid url for non-animated images. Consider using the `prefer_animated` parameter instead.
* When passing `i_gif`, it returns an empty string for non-animated images. Consider using the `prefer_animated` parameter instead.
* @param prefer_animated Whether you prefer gif format.
* If true, it'll return gif format whenever the image is available as animated.
* @return std::string avatar url or an empty string, if required attributes are missing or an invalid format was passed
@ -305,7 +305,7 @@ public:
bool has_animated_icon() const;
/**
* @brief Format a username into user#discriminator
* @brief Format a username into user\#discriminator
*
* For example Brain#0001
*
@ -371,7 +371,7 @@ public:
* @param size The size of the banner in pixels. It can be any power of two between 16 and 4096,
* otherwise the default sized banner is returned.
* @param format The format to use for the avatar. It can be one of `i_webp`, `i_jpg`, `i_png` or `i_gif`.
* Passing `i_gif` might result in an invalid url for non-animated images. Consider using the `prefer_animated` parameter instead.
* When passing `i_gif`, it returns an empty string for non-animated images. Consider using the `prefer_animated` parameter instead.
* @param prefer_animated Whether you prefer gif format.
* If true, it'll return gif format whenever the image is available as animated.
* @return std::string banner url or an empty string, if required attributes are missing or an invalid format was passed

View File

@ -39,11 +39,54 @@
* @brief The main namespace for D++ functions, classes and types
*/
namespace dpp {
enum sticker_format : uint8_t;
/**
* @brief Utility helper functions, generally for logging, running programs, time/date manipulation, etc
*/
namespace utility {
/**
* For internal use only. Helper function to easily create discord's cdn endpoint urls
* @see https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints
* @param allowed_formats A vector of supported formats for the endpoint from the discord docs
* @param path_without_extension The path for the endpoint (without the extension e.g. `.png`)
* @param format the wished format to return. Must be one of the formats passed in `allowed_formats`, otherwise it returns an empty string
* @param 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)
* @param prefer_animated Whether the user prefers gif format. If true, it'll return gif format whenever the emoji is available as animated.
* In this case, the `format`-parameter is only used for non-animated images.
* @param is_animated Whether the image is actually animated or not
* @return std::string endpoint url or empty string
*/
std::string 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);
/**
* For internal use only. Helper function to easily create discord's cdn endpoint urls
* @see https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints
* @param allowed_formats A vector of supported formats for the endpoint from the discord docs
* @param path_without_extension The path for the endpoint (without the extension e.g. `.png`)
* @param hash The hash (optional). If passed, it will be prefixed with `a_` for animated images (`is_animated`=true)
* @param format the wished format to return. Must be one of the formats passed in `allowed_formats`, otherwise it returns an empty string
* @param 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)
* @param prefer_animated Whether the user prefers gif format. If true, it'll return gif format whenever the emoji is available as animated.
* In this case, the `format`-parameter is only used for non-animated images.
* @param is_animated Whether the image is actually animated or not
* @return std::string endpoint url or empty string
*/
std::string 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);
/**
* For internal use only. Helper function to easily create discord's cdn endpoint urls (specialised for stickers)
* @see https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints
* @param sticker_id The sticker ID. Returns empty string if 0
* @param format The format type
* @return std::string endpoint url or empty string
*/
std::string cdn_endpoint_url_sticker(snowflake sticker_id, sticker_format format);
/**
* @brief Timestamp formats for dpp::utility::timestamp()
*
@ -344,7 +387,7 @@ namespace dpp {
* @note Be aware this function can block! If you are regularly reading large files, consider caching them.
* @param filename The path to the file to read
* @return std::string The file contents
* @throw dpp::exception on failure to read the entire file
* @throw dpp::file_exception on failure to read the entire file
*/
std::string DPP_EXPORT read_file(const std::string& filename);

View File

@ -21,9 +21,9 @@
#pragma once
#if !defined(DPP_VERSION_LONG)
#define DPP_VERSION_LONG 0x00100023
#define DPP_VERSION_SHORT 100023
#define DPP_VERSION_TEXT "D++ 10.0.23 (04-Jan-2023)"
#define DPP_VERSION_LONG 0x00100024
#define DPP_VERSION_SHORT 100024
#define DPP_VERSION_TEXT "D++ 10.0.24 (28-Feb-2023)"
#define DPP_VERSION_MAJOR ((DPP_VERSION_LONG & 0x00ff0000) >> 16)
#define DPP_VERSION_MINOR ((DPP_VERSION_LONG & 0x0000ff00) >> 8)

View File

@ -61,6 +61,7 @@ public:
* @brief Construct a new webhook object using the Webhook URL provided by Discord
*
* @param webhook_url a fully qualified web address of an existing webhook
* @throw logic_exception if the webhook url could not be parsed
*/
webhook(const std::string& webhook_url);

View File

@ -27,7 +27,6 @@
* Before adding a warning here please be ABSOLUTELY SURE it is one we cannot easily fix
* and is to be silenced, thrown into the sarlacc pit to be eaten for 1000 years...
*/
#if !defined(__MINGW__) && !defined(__MINGW32__) && !defined(__MINGW64__)
_Pragma("warning( disable : 4251 )"); // 4251 warns when we export classes or structures with stl member variables
_Pragma("warning( disable : 5105 )"); // 5105 is to do with macro warnings
#endif
_Pragma("warning( disable : 4251 )"); // 4251 warns when we export classes or structures with stl member variables
_Pragma("warning( disable : 5105 )"); // 5105 is to do with macro warnings