Created the coins.cpp command
This commit is contained in:
parent
92b2767c55
commit
54385d0a7c
19
src/commands/coins.cpp
Normal file
19
src/commands/coins.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "coins.h"
|
||||
#include "api/util.h"
|
||||
|
||||
#define COINS 1000
|
||||
|
||||
void coins::execute(sql::Connection &con, dpp::cluster &bot, const dpp::slashcommand_t &event) {
|
||||
sql::ResultSet *res = util::getResultSet(con, "SELECT coins FROM guilds WHERE guildId = ?", {event.command.guild_id.str()});
|
||||
int coins;
|
||||
|
||||
if (!res->next()) {
|
||||
util::executeQuery(con, "INSERT INTO guilds (guildId, coins) VALUES (?, ?)", {event.command.guild_id.str(), std::to_string(COINS)});
|
||||
coins = COINS;
|
||||
} else {
|
||||
coins = res->getInt("coins");
|
||||
}
|
||||
|
||||
util::sendSuccess(event, "You have " + std::to_string(coins) + " coins.");
|
||||
delete res;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user