diff options
| author | garder500 <jeremy27.clara22@gmail.com> | 2025-04-26 15:56:16 +0200 |
|---|---|---|
| committer | garder500 <jeremy27.clara22@gmail.com> | 2025-04-26 15:56:16 +0200 |
| commit | bd508f4a3c7fc18f053696148f614851cfb0d448 (patch) | |
| tree | baa8368af27b5b313d39db90e395c332ea24f130 /bot/src/main.cpp | |
| parent | d6a9644c909b246491a8b642c08dd8103c06fa0a (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/src/main.cpp')
| -rw-r--r-- | bot/src/main.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bot/src/main.cpp b/bot/src/main.cpp new file mode 100644 index 0000000..500170d --- /dev/null +++ b/bot/src/main.cpp @@ -0,0 +1,28 @@ +#include <dpp/dpp.h> +#include "../include/utils.hpp" +const std::string BOT_TOKEN = getenv("BOT_TOKEN"); + +int main() { + dpp::cluster bot(BOT_TOKEN); + + bot.on_log(dpp::utility::cout_logger()); + + bot.on_slashcommand([](const dpp::slashcommand_t& event) { + // let's generate the key-value map + std::map<std::string, std::string> key_values = app::generate_key_values(event); + // let's create a string to send + std::string response = "Pong! ((userName))"; + + if (event.command.get_command_name() == "ping") { + event.reply(app::update_string(response, key_values)); + } + }); + + bot.on_ready([&bot](const dpp::ready_t& event) { + if (dpp::run_once<struct register_bot_commands>()) { + bot.global_command_create(dpp::slashcommand("ping", "Ping pong!", bot.me.id)); + } + }); + + bot.start(dpp::st_wait); +} |
