Added bot parameter to all methods and get_pfp
This commit is contained in:
@@ -7,6 +7,12 @@
|
||||
// Command ping
|
||||
#define COMMAND_PING_DESCRIPTION "Ping-pong test"
|
||||
|
||||
// Command get_pfp
|
||||
#define COMMAND_GET_PFP_DESCRIPTION \
|
||||
"Get someone elses profile picture as a picture"
|
||||
#define COMMAND_GET_PFP_ARGS_USER \
|
||||
"Whose profile picture do you want to get(it can be yourself)"
|
||||
|
||||
// Command about
|
||||
#define COMMAND_ABOUT_DESCRIPTION "Info about the bot"
|
||||
#define COMMAND_ABOUT_RESPONSE \
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include "../CommandManagement.cpp"
|
||||
#include "../Databases.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <dpp/cluster.h>
|
||||
#include <dpp/dispatcher.h>
|
||||
#include <dpp/dpp.h>
|
||||
@@ -17,10 +18,10 @@ int main(int argc, char **argv) {
|
||||
// Neat utility
|
||||
bot.on_log(dpp::utility::cout_logger());
|
||||
|
||||
bot.on_slashcommand([](const dpp::slashcommand_t &event) {
|
||||
bot.on_slashcommand([&bot](const dpp::slashcommand_t &event) {
|
||||
auto command = Commands.find(event.command.get_command_name());
|
||||
if (command != Commands.end()) {
|
||||
command->second(event);
|
||||
command->second(event, bot);
|
||||
return;
|
||||
}
|
||||
event.reply("Could not find that command :(");
|
||||
|
@@ -3,8 +3,9 @@
|
||||
#include <dpp/cluster.h>
|
||||
#include <dpp/dispatcher.h>
|
||||
|
||||
extern std::unordered_map<std::string,
|
||||
std::function<void(const dpp::slashcommand_t &event)>>
|
||||
extern std::unordered_map<
|
||||
std::string,
|
||||
std::function<void(const dpp::slashcommand_t &event, dpp::cluster &bot)>>
|
||||
Commands;
|
||||
|
||||
void deleteCommands(const dpp::ready_t &event, dpp::cluster &bot) {
|
||||
@@ -63,4 +64,11 @@ void createCommands(const dpp::ready_t &event, dpp::cluster &bot) {
|
||||
dpp::slashcommand("money_leaderboard",
|
||||
COMMAND_MONEY_LEADERBOARD_DESCRIPTION, bot.me.id),
|
||||
GUILD);
|
||||
|
||||
bot.guild_command_create(
|
||||
dpp::slashcommand("get_pfp", COMMAND_GET_PFP_DESCRIPTION, bot.me.id)
|
||||
.add_option(dpp::command_option(dpp::command_option_type::co_user,
|
||||
"user", COMMAND_GET_PFP_ARGS_USER,
|
||||
true)),
|
||||
GUILD);
|
||||
}
|
||||
|
@@ -3,8 +3,9 @@
|
||||
#include "Commands/OtherCommands.cpp"
|
||||
|
||||
// Registry
|
||||
std::unordered_map<std::string,
|
||||
std::function<void(const dpp::slashcommand_t &event)>>
|
||||
std::unordered_map<
|
||||
std::string,
|
||||
std::function<void(const dpp::slashcommand_t &event, dpp::cluster &bot)>>
|
||||
Commands{{"ping", commandPing},
|
||||
{"about", commandAbout},
|
||||
{"balance", commandBalance},
|
||||
@@ -12,4 +13,5 @@ std::unordered_map<std::string,
|
||||
{"pay", commandPay},
|
||||
{"print_money", commandPrintMoney},
|
||||
{"burn_money", commandBurnMoney},
|
||||
{"money_leaderboard", commandMoneyLeaderboard}};
|
||||
{"money_leaderboard", commandMoneyLeaderboard},
|
||||
{"get_pfp", commandGetPFP}};
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include <variant>
|
||||
|
||||
// Actual commands
|
||||
void commandBalance(const dpp::slashcommand_t &event) {
|
||||
void commandBalance(const dpp::slashcommand_t &event, dpp::cluster &bot) {
|
||||
std::string person, balance;
|
||||
dpp::command_value id = event.get_parameter("user");
|
||||
|
||||
@@ -29,7 +29,7 @@ void commandBalance(const dpp::slashcommand_t &event) {
|
||||
event.reply(COMMAND_BALANCE_SOMEONE_ELSE_RESPONSE(person, balance));
|
||||
}
|
||||
|
||||
void commandPay(const dpp::slashcommand_t &event) {
|
||||
void commandPay(const dpp::slashcommand_t &event, dpp::cluster &bot) {
|
||||
std::string recipient =
|
||||
std::get<dpp::snowflake>(event.get_parameter("recipient")).str();
|
||||
std::uint64_t amount = std::get<std::int64_t>(event.get_parameter("amount"));
|
||||
@@ -46,7 +46,7 @@ void commandPay(const dpp::slashcommand_t &event) {
|
||||
event.reply(COMMAND_PAY_SUCCESS(recipient, std::to_string(amount)));
|
||||
}
|
||||
|
||||
void commandPrintMoney(const dpp::slashcommand_t &event) {
|
||||
void commandPrintMoney(const dpp::slashcommand_t &event, dpp::cluster &bot) {
|
||||
std::int64_t userid = event.command.get_issuing_user().id;
|
||||
|
||||
if (ADMIN_ID != userid) {
|
||||
@@ -59,7 +59,7 @@ void commandPrintMoney(const dpp::slashcommand_t &event) {
|
||||
COMMAND_PRINT_SUCCESS(std::to_string(ADMIN_ID), std::to_string(amount)));
|
||||
}
|
||||
|
||||
void commandBurnMoney(const dpp::slashcommand_t &event) {
|
||||
void commandBurnMoney(const dpp::slashcommand_t &event, dpp::cluster &bot) {
|
||||
std::int64_t userid = event.command.get_issuing_user().id;
|
||||
|
||||
if (ADMIN_ID != userid) {
|
||||
@@ -78,7 +78,8 @@ void commandBurnMoney(const dpp::slashcommand_t &event) {
|
||||
COMMAND_BURN_SUCCESS(std::to_string(ADMIN_ID), std::to_string(amount)));
|
||||
}
|
||||
|
||||
void commandMoneyLeaderboard(const dpp::slashcommand_t &event) {
|
||||
void commandMoneyLeaderboard(const dpp::slashcommand_t &event,
|
||||
dpp::cluster &bot) {
|
||||
std::string result;
|
||||
std::stringstream replyStream;
|
||||
execSQL("SELECT * FROM MONEY ORDER BY CASH DESC LIMIT 15;", &result);
|
||||
|
@@ -1,7 +1,15 @@
|
||||
#include "../../settings.hpp"
|
||||
#include <dpp/dispatcher.h>
|
||||
#include <dpp/guild.h>
|
||||
#include <dpp/snowflake.h>
|
||||
|
||||
void commandPing(const dpp::slashcommand_t &event) { event.reply("Pong"); }
|
||||
void commandAbout(const dpp::slashcommand_t &event) {
|
||||
void commandPing(const dpp::slashcommand_t &event, dpp::cluster &bot) {
|
||||
event.reply("Pong");
|
||||
}
|
||||
void commandAbout(const dpp::slashcommand_t &event, dpp::cluster &bot) {
|
||||
event.reply(COMMAND_ABOUT_RESPONSE);
|
||||
}
|
||||
|
||||
void commandGetPFP(const dpp::slashcommand_t &event, dpp::cluster &bot) {
|
||||
dpp::snowflake user = std::get<dpp::snowflake>(event.get_parameter("user"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user