Created the channel.cpp command
This commit is contained in:
parent
d53c01c734
commit
8941b875ea
28
src/commands/channel.cpp
Normal file
28
src/commands/channel.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "channel.h"
|
||||
#include "api/util.h"
|
||||
|
||||
void channel::execute(sql::Connection &con, dpp::cluster &bot, const dpp::slashcommand_t &event) {
|
||||
std::string cmd = event.command.get_command_interaction().options[0].name;
|
||||
|
||||
sql::ResultSet *res = util::getResultSet(con, "SELECT * FROM `channels` WHERE `channelId` = ? AND `guildId` = ?",
|
||||
{event.command.channel_id.str(), event.command.guild_id.str()});
|
||||
|
||||
if (!res->next()) {
|
||||
util::sendError(event, "This channel is not a global chat!");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string value = std::get<std::string>(event.command.get_command_interaction().options[0].options[0].value);
|
||||
if (cmd == "language") {
|
||||
util::executeQuery(con, "UPDATE `channels` SET `langCode` = ? WHERE `channelId` = ? AND `guildId` = ?",
|
||||
{value, event.command.channel_id.str(), event.command.guild_id.str()});
|
||||
util::sendSuccess(event, "The language of this channel has been updated.");
|
||||
} else if (cmd == "topic") {
|
||||
util::executeQuery(con, "UPDATE `channels` SET `topicId` = ? WHERE `channelId` = ? AND `guildId` = ?",
|
||||
{value, event.command.channel_id.str(), event.command.guild_id.str()});
|
||||
util::sendSuccess(event, "The topic of this channel has been updated.");
|
||||
} else {
|
||||
util::sendError(event, "Invalid subcommand.");
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user