Added a security check to the add.cpp

This commit is contained in:
Mathias Wagner 2023-11-04 14:08:57 +01:00
parent d151338206
commit f42b40091b
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -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;