Created the remove.cpp
This commit is contained in:
parent
f42b40091b
commit
204fdcc0b6
26
src/commands/remove.cpp
Normal file
26
src/commands/remove.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "remove.h"
|
||||||
|
#include <api/util.h>
|
||||||
|
|
||||||
|
void remove::execute(sql::Connection &con, dpp::cluster &bot, const dpp::slashcommand_t &event) {
|
||||||
|
dpp::channel channel = event.command.get_command_interaction().options.empty() ? event.command.channel
|
||||||
|
: event.command.get_resolved_channel(
|
||||||
|
std::get<dpp::snowflake>(event.get_parameter("channel")));
|
||||||
|
|
||||||
|
if (channel.get_type() != dpp::channel_type::CHANNEL_TEXT) {
|
||||||
|
util::sendError(event, "You can only remove text channels!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sql::ResultSet *res = util::getResultSet(con, "SELECT * FROM `channels` WHERE `channelId` = ? AND `guildId` = ?",
|
||||||
|
{channel.id.str(), channel.guild_id.str()});
|
||||||
|
|
||||||
|
if (res->next()) {
|
||||||
|
util::sendSuccess(event, "This channel is no longer a global chat channel!");
|
||||||
|
util::executeQuery(con, "DELETE FROM `channels` WHERE `channelId` = ? AND `guildId` = ?",
|
||||||
|
{channel.id.str(), channel.guild_id.str()});
|
||||||
|
} else {
|
||||||
|
util::sendError(event, "This channel is not in the global chat!");
|
||||||
|
}
|
||||||
|
|
||||||
|
delete res;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user