diff --git a/languages/locale_en.hpp b/languages/locale_en.hpp index a714e2a..24293c4 100644 --- a/languages/locale_en.hpp +++ b/languages/locale_en.hpp @@ -14,6 +14,12 @@ "Upload a background image to use (Only supports PNG, JPEG, and WEBP files)" #define COMMAND_GENERATE_REPORT_ARGS_HEADLINE_DESCRIPTION \ "What is the headline?" +#define COMMAND_GENERATE_REPORT_FAIL_NOT_SUPPORTED(filetype) \ + "File type: " + filetype + \ + " is not allowed. Only PNG, JPEG, and WEBP are allowed!" +#define COMMAND_GENERATE_REPORT_FAIL_IMAGE_LOAD \ + "Failed to load the background image! Aborting. You were not changed for " \ + "this." // Command get_pfp #define COMMAND_GET_PFP "get_pfp" diff --git a/src/Commands/GenerativeCommands.cpp b/src/Commands/GenerativeCommands.cpp index 12eb992..227275d 100644 --- a/src/Commands/GenerativeCommands.cpp +++ b/src/Commands/GenerativeCommands.cpp @@ -23,13 +23,14 @@ void commandGenerateReport(const dpp::slashcommand_t &event, std::get(event.get_parameter("image")); dpp::attachment file = event.command.get_resolved_attachment(fileId); auto fileType = supportedImageFileTypes.find(file.content_type); + if (fileType != supportedImageFileTypes.end()) { bot.request( file.url, dpp::http_method::m_get, [event, &bot, fileType](const dpp::http_request_completion_t &result) { auto imageAsSurface = fileType->second(result.body); if (imageAsSurface == nullptr) { - event.edit_response("Failed to load the background image :("); + event.edit_response(COMMAND_GENERATE_REPORT_FAIL_IMAGE_LOAD); return; } @@ -49,8 +50,7 @@ void commandGenerateReport(const dpp::slashcommand_t &event, }); } else { event.edit_response( - "File type: " + file.content_type + - " is not allowed. Only PNG, JPEG, and WEBP are allowed!"); + COMMAND_GENERATE_REPORT_FAIL_NOT_SUPPORTED(file.content_type)); } }