From 20a9112a21b9e249166db0cfd3eaaa4379078d41 Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Thu, 19 Aug 2021 23:01:12 +0200 Subject: [PATCH 1/2] Fix Embed Construction Order --- core/include/config_manager.h | 2 +- core/src/config_manager.cpp | 6 ++++-- core/src/discord.cpp | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/include/config_manager.h b/core/include/config_manager.h index 9af71b3..edbf931 100644 --- a/core/include/config_manager.h +++ b/core/include/config_manager.h @@ -217,7 +217,7 @@ class ConfigManager { * * @return See short description. */ - static QString discordWebhookContent(); + static QString discordModcallWebhookContent(); /** * @brief Returns true if the discord webhook should send log files. diff --git a/core/src/config_manager.cpp b/core/src/config_manager.cpp index 49e1401..a8ac6be 100644 --- a/core/src/config_manager.cpp +++ b/core/src/config_manager.cpp @@ -17,6 +17,8 @@ ////////////////////////////////////////////////////////////////////////////////////// #include "include/config_manager.h" +#include + QSettings* ConfigManager::m_settings = new QSettings("config/config.ini", QSettings::IniFormat); QSettings* ConfigManager::m_discord = new QSettings("config/discord.ini", QSettings::IniFormat); ConfigManager::CommandSettings* ConfigManager::m_commands = new CommandSettings(); @@ -285,9 +287,9 @@ QString ConfigManager::discordModcallWebhookUrl() return m_discord->value("Discord/webhook_modcall_url", "").toString(); } -QString ConfigManager::discordWebhookContent() +QString ConfigManager::discordModcallWebhookContent() { - return m_discord->value("Discord/webhook_content", "").toString(); + return m_discord->value("Discord/webhook_modcall_content", "").toString(); } bool ConfigManager::discordModcallWebhookSendFile() diff --git a/core/src/discord.cpp b/core/src/discord.cpp index 3fd8e94..d0f093b 100644 --- a/core/src/discord.cpp +++ b/core/src/discord.cpp @@ -71,9 +71,9 @@ QJsonDocument Discord::constructModcallJson(const QString &f_name, const QString {"description", f_reason} }; l_array.append(l_object); + l_json["content"] = ConfigManager::discordModcallWebhookContent(); l_json["embeds"] = l_array; - if (!ConfigManager::discordWebhookContent().isEmpty()) - l_json["content"] = ConfigManager::discordWebhookContent(); + return QJsonDocument(l_json); } From 378b21099dec89d8ecefec1d9091ffa79c623884 Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Thu, 19 Aug 2021 23:04:23 +0200 Subject: [PATCH 2/2] Add check for empty string --- core/src/discord.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/discord.cpp b/core/src/discord.cpp index d0f093b..1526101 100644 --- a/core/src/discord.cpp +++ b/core/src/discord.cpp @@ -71,6 +71,8 @@ QJsonDocument Discord::constructModcallJson(const QString &f_name, const QString {"description", f_reason} }; l_array.append(l_object); + + if (!ConfigManager::discordModcallWebhookContent().isEmpty()) l_json["content"] = ConfigManager::discordModcallWebhookContent(); l_json["embeds"] = l_array;