summaryrefslogtreecommitdiff
path: root/bot/include/utils.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'bot/include/utils.hpp')
-rw-r--r--bot/include/utils.hpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/bot/include/utils.hpp b/bot/include/utils.hpp
index 19c834c..57f4005 100644
--- a/bot/include/utils.hpp
+++ b/bot/include/utils.hpp
@@ -37,7 +37,7 @@ namespace app
* @param updates A map of key-value pairs to replace placeholders
* @return std::string The updated string with placeholders replaced
*/
- std::string update_string(const std::string &initial, const std::map<std::string, std::string> &updates);
+ std::string update_string(const std::string &initial, const std::unordered_map<std::string, std::string> &updates);
/**
* @brief Processes a command option recursively and adds values to the key-value map
@@ -46,7 +46,7 @@ namespace app
* @param option The command option to process
* @param kv The key-value map to update
*/
- void process_interaction_option(const slashcommand_t &event, const command_data_option &option, std::map<std::string, std::string> &kv);
+ void process_interaction_option(const slashcommand_t &event, const command_data_option &option, std::unordered_map<std::string, std::string> &kv);
/**
* @brief Generates a map of key-value pairs from a slash command event
@@ -54,7 +54,23 @@ namespace app
* @param event The slash command event
* @return std::map<std::string, std::string> A map containing information about the command, user, guild, and options
*/
- std::map<std::string, std::string> generate_key_values(const slashcommand_t &event);
+ std::unordered_map<std::string, std::string> generate_key_values(const slashcommand_t &event);
+
+ /**
+ * @brief Parses a JSON string into a JSON object
+ *
+ * @param str The JSON string to parse
+ * @return nlohmann::json The parsed JSON object
+ */
+ nlohmann::json json_from_string(const std::string &str);
+
+ /**
+ * @brief Converts a JSON object into a string
+ *
+ * @param j The JSON object to convert
+ * @return std::string The string representation of the JSON object
+ */
+ std::string string_from_json(const nlohmann::json &j);
} // namespace dpp