blob: 19c834c5ef627ca2145d24e6675aedf0038315d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
  |