Organised command adding/removing
This commit is contained in:
21
src/CommandEvents.cpp
Normal file
21
src/CommandEvents.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "Commands.hpp"
|
||||
#include "../languages/locale_en.hpp"
|
||||
#include "Base/SQL.hpp"
|
||||
#include <dpp/snowflake.h>
|
||||
|
||||
void commandPing(const dpp::slashcommand_t &event) { event.reply("Pong"); }
|
||||
void commandBalance(const dpp::slashcommand_t &event) {
|
||||
dpp::snowflake userid = event.command.get_issuing_user().id;
|
||||
std::string balance;
|
||||
execSQL("SELECT CASH FROM MONEY WHERE UID=" + userid.str(), &balance);
|
||||
|
||||
if (balance.empty()) {
|
||||
execSQL("INSERT INTO MONEY (UID) VALUES (" + userid.str() + ");");
|
||||
balance = "0";
|
||||
} else {
|
||||
std::uint8_t begining = balance.find(':') + 1;
|
||||
balance = balance.substr(begining, balance.find(';') - begining);
|
||||
}
|
||||
|
||||
event.reply(COMMAND_BALANCE_RESPONSE(balance));
|
||||
}
|
Reference in New Issue
Block a user