Added printing money, will rename
This commit is contained in:
@@ -44,6 +44,22 @@ void commandPay(const dpp::slashcommand_t &event) {
|
||||
event.reply(COMMAND_PAY_SUCCESS(recipient, std::to_string(amount)));
|
||||
}
|
||||
|
||||
void commandPrintMoney(const dpp::slashcommand_t &event) {
|
||||
std::int64_t userid = event.command.get_issuing_user().id;
|
||||
|
||||
if (ADMIN_ID != userid) {
|
||||
event.reply(COMMAND_PRINT_FAIL_NO_PRIVILIEGE);
|
||||
return;
|
||||
}
|
||||
std::uint64_t amount = std::get<std::int64_t>(event.get_parameter("amount"));
|
||||
increaseFromUsersBalance(ADMIN_ID, amount);
|
||||
event.reply(COMMAND_PRINT_SUCCESS(std::to_string(amount)));
|
||||
}
|
||||
|
||||
///
|
||||
/// HELPER INLINE METHODS
|
||||
///
|
||||
|
||||
inline void increaseFromUsersBalance(const dpp::snowflake userid,
|
||||
std::uint64_t amount) {
|
||||
std::uint64_t balance = std::stoi(getUserBalance(userid));
|
||||
|
@@ -29,4 +29,12 @@ void createCommands(const dpp::ready_t &event, dpp::cluster &bot) {
|
||||
COMMAND_PAY_ARGS_AMOUNT_DESCRIPTION, true)
|
||||
.set_min_value(1)),
|
||||
GUILD);
|
||||
|
||||
bot.guild_command_create(
|
||||
dpp::slashcommand("print_cash", COMMAND_PRINT_DESCRIPTION, bot.me.id)
|
||||
.add_option(dpp::command_option(
|
||||
dpp::command_option_type::co_integer, "amount",
|
||||
COMMAND_PRINT_ARGS_AMOUNT_DESCRIPTION, true)
|
||||
.set_min_value(1)),
|
||||
GUILD);
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ void createCommands(const dpp::ready_t &event, dpp::cluster &bot);
|
||||
void commandPing(const dpp::slashcommand_t &event);
|
||||
void commandBalance(const dpp::slashcommand_t &event);
|
||||
void commandPay(const dpp::slashcommand_t &event);
|
||||
void commandPrintMoney(const dpp::slashcommand_t &event);
|
||||
|
||||
// Inline helpers
|
||||
inline void increaseFromUsersBalance(const dpp::snowflake userid,
|
||||
@@ -21,9 +22,8 @@ inline void addUserToDatabase(const dpp::snowflake userid);
|
||||
|
||||
inline std::unordered_map<std::string,
|
||||
std::function<void(const dpp::slashcommand_t &event)>>
|
||||
Commands{
|
||||
{"ping", commandPing},
|
||||
{"balance", commandBalance},
|
||||
{"bal", commandBalance},
|
||||
{"pay", commandPay},
|
||||
};
|
||||
Commands{{"ping", commandPing},
|
||||
{"balance", commandBalance},
|
||||
{"bal", commandBalance},
|
||||
{"pay", commandPay},
|
||||
{"print_cash", commandPrintMoney}};
|
||||
|
Reference in New Issue
Block a user