summaryrefslogtreecommitdiff
path: root/bot/include/utils.hpp
diff options
context:
space:
mode:
authorgarder500 <jeremy27.clara22@gmail.com>2025-04-27 16:06:19 +0200
committergarder500 <jeremy27.clara22@gmail.com>2025-04-27 16:06:19 +0200
commit7cbd16f1b3115d3335c61e7c82e349594a726f52 (patch)
tree7a36ded6b73d924b6891ac052140f69bf73c33ac /bot/include/utils.hpp
parentb3791125200154278d31514217c4f417d8961e84 (diff)
Ajout de la logique de connexion et de gestion des signaux pour le bot Discord, ainsi que des améliorations dans la gestion des chaînes JSON et des mises à jour des commandes.
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