summaryrefslogtreecommitdiff
path: root/bot/include/utils.hpp
diff options
context:
space:
mode:
authorgarder500 <jeremy27.clara22@gmail.com>2025-04-26 15:56:16 +0200
committergarder500 <jeremy27.clara22@gmail.com>2025-04-26 15:56:16 +0200
commitbd508f4a3c7fc18f053696148f614851cfb0d448 (patch)
treebaa8368af27b5b313d39db90e395c332ea24f130 /bot/include/utils.hpp
parentd6a9644c909b246491a8b642c08dd8103c06fa0a (diff)
Ajout de la configuration de l'environnement de développement, des fichiers de projet et des utilitaires pour le bot Discord.
Diffstat (limited to 'bot/include/utils.hpp')
-rw-r--r--bot/include/utils.hpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/bot/include/utils.hpp b/bot/include/utils.hpp
new file mode 100644
index 0000000..19c834c
--- /dev/null
+++ b/bot/include/utils.hpp
@@ -0,0 +1,62 @@
+// utils.hpp
+
+#ifndef UTILS_HPP
+#define UTILS_HPP
+
+#include <dpp/dpp.h>
+#include <dpp/nlohmann/json.hpp>
+#include <map>
+#include <string>
+#include <regex>
+#include <sstream>
+#include <algorithm>
+using namespace dpp;
+namespace app
+{
+
+ /**
+ * @brief Creates a URL for a user's avatar
+ *
+ * @param u The user object
+ * @return std::string The URL to the user's avatar
+ */
+ std::string make_avatar_url(const user &u);
+
+ /**
+ * @brief Creates a URL for a guild's icon
+ *
+ * @param g The guild object
+ * @return std::string The URL to the guild's icon
+ */
+ std::string make_guild_icon(const guild &g);
+
+ /**
+ * @brief Updates a string by replacing placeholders with values from a map
+ *
+ * @param initial The initial string with placeholders in the format ((key))
+ * @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);
+
+ /**
+ * @brief Processes a command option recursively and adds values to the key-value map
+ *
+ * @param event The slash command event
+ * @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);
+
+ /**
+ * @brief Generates a map of key-value pairs from a slash command event
+ *
+ * @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);
+
+} // namespace dpp
+
+#endif // UTILS_HPP
+// utils.hpp