From bd508f4a3c7fc18f053696148f614851cfb0d448 Mon Sep 17 00:00:00 2001 From: garder500 Date: Sat, 26 Apr 2025 15:56:16 +0200 Subject: Ajout de la configuration de l'environnement de développement, des fichiers de projet et des utilitaires pour le bot Discord. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/src/main.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bot/src/main.cpp (limited to 'bot/src') 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 +#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 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()) { + bot.global_command_create(dpp::slashcommand("ping", "Ping pong!", bot.me.id)); + } + }); + + bot.start(dpp::st_wait); +} -- cgit v1.2.3