From f42b40091b97e6997d8c085dae127761a7e37066 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 4 Nov 2023 14:08:57 +0100 Subject: [PATCH] Added a security check to the add.cpp --- src/commands/add.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/commands/add.cpp b/src/commands/add.cpp index 2a77ebb..dfb6092 100644 --- a/src/commands/add.cpp +++ b/src/commands/add.cpp @@ -6,6 +6,11 @@ using namespace sql; using json = nlohmann::json; void add::execute(sql::Connection &con, dpp::cluster &bot, const dpp::slashcommand_t &event) { + if (event.command.channel.get_type() != dpp::channel_type::CHANNEL_TEXT) { + util::sendError(event, "This command can only be used in text channels."); + return; + } + ResultSet *res = util::getResultSet(con, "SELECT * FROM channels WHERE guildId = ? AND channelId = ?", {event.command.guild_id.str(), event.command.channel_id.str()}); if (res->next()) { @@ -13,6 +18,8 @@ void add::execute(sql::Connection &con, dpp::cluster &bot, const dpp::slashcomma return; } + delete res; + dpp::webhook newWebhook = dpp::webhook(); newWebhook.name = "Sheepstar"; newWebhook.channel_id = event.command.channel_id;