summaryrefslogtreecommitdiff
path: root/bot/src
diff options
context:
space:
mode:
authorsoler_j <soler_j@etna-alternance.net>2025-04-30 01:24:34 +0200
committersoler_j <soler_j@etna-alternance.net>2025-04-30 01:24:34 +0200
commit76b447e1d67389618a027c692f76f937162c5646 (patch)
treee0de726e9c7ee171370a66bfa33422211745732d /bot/src
parent1d575366a05b93fd7170f851bece8cdd52c4f6db (diff)
Ajout de l'handle des "actions"
- Première action disponible "suppression de message"
Diffstat (limited to 'bot/src')
-rw-r--r--bot/src/main.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/bot/src/main.cpp b/bot/src/main.cpp
index 4418b6f..da38d43 100644
--- a/bot/src/main.cpp
+++ b/bot/src/main.cpp
@@ -18,18 +18,24 @@ int main(int argc, char* argv[]) {
bot.on_log(dpp::utility::cout_logger());
- bot.on_slashcommand([&json_data](const dpp::slashcommand_t& event) {
+ bot.on_slashcommand([&json_data, &bot](const dpp::slashcommand_t& event) {
std::unordered_map<std::string, std::string> key_values = app::generate_key_values(event);
std::string command_name = event.command.get_command_name();
std::string response = "Interaction found, but no response found.";
if (!command_name.empty() && json_data->contains(command_name)) {
auto& command_data = (*json_data)[command_name];
- if (command_data.contains("response")) {
+ bool no_error = true;
+ if (command_data.contains("action")) {
+ auto& action = command_data["action"];
+ // Actions are a list of Objects
+ if (action.is_array()) {
+ no_error = app::handle_actions(event, action, key_values, bot);
+ }
+ }
+ if (command_data.contains("response") && no_error) {
response = command_data["response"];
std::cout << "Command: " << command_name << " → Response: " << response << std::endl;
- } else {
- std::cout << "No response found for command: " << command_name << std::endl;
}
}