Added printing money, will rename
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "../token.h"
|
||||
#define CURRENCY_NAME "Night Coin"
|
||||
|
||||
#define COMMAND_BALANCE_DESCRIPTION "See someone's balance of " CURRENCY_NAME
|
||||
@@ -16,3 +17,11 @@
|
||||
" " CURRENCY_NAME "(s)!"
|
||||
#define COMMAND_PAY_SUCCESS(recipient, amount) \
|
||||
"Successfully sent <@!" + recipient + "> " + amount + " " CURRENCY_NAME "(s)!"
|
||||
|
||||
#define COMMAND_PRINT_DESCRIPTION "Allows the admin to print money on-demand"
|
||||
#define COMMAND_PRINT_ARGS_AMOUNT_DESCRIPTION "How much are we printing boss?"
|
||||
#define COMMAND_PRINT_FAIL_NO_PRIVILIEGE \
|
||||
"Only <@!" + std::to_string(ADMIN_ID) + "> can print money!"
|
||||
#define COMMAND_PRINT_SUCCESS(amount) \
|
||||
"Successfully printed " + amount + " " CURRENCY_NAME "(s) to <@!" + \
|
||||
std::to_string(ADMIN_ID) + "> !"
|
||||
|
@@ -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},
|
||||
Commands{{"ping", commandPing},
|
||||
{"balance", commandBalance},
|
||||
{"bal", commandBalance},
|
||||
{"pay", commandPay},
|
||||
};
|
||||
{"print_cash", commandPrintMoney}};
|
||||
|
Reference in New Issue
Block a user