Organised command adding/removing
This commit is contained in:
@@ -6,7 +6,8 @@ project(TheBartender VERSION 1.0)
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
# Create an executable
|
||||
add_executable(${PROJECT_NAME} src/Base/Entry.cpp src/Commands.cpp)
|
||||
add_executable(${PROJECT_NAME} src/Base/Entry.cpp src/CommandEvents.cpp
|
||||
src/CommandManagement.cpp)
|
||||
|
||||
# Find our pre-installed DPP package (using FindDPP.cmake).
|
||||
find_package(DPP REQUIRED)
|
||||
|
@@ -29,17 +29,12 @@ int main(int argc, char **argv) {
|
||||
});
|
||||
|
||||
bot.on_ready([&bot](const dpp::ready_t &event) {
|
||||
if (dpp::run_once<struct register_bot_commands>()) {
|
||||
bot.global_command_create(
|
||||
dpp::slashcommand("ping", "Ping-pong test", bot.me.id));
|
||||
bot.guild_command_create(
|
||||
dpp::slashcommand("balance", COMMAND_BALANCE_DESCRIPTION, bot.me.id),
|
||||
GUILD);
|
||||
}
|
||||
|
||||
if (dpp::run_once<struct clear_bot_commands>()) {
|
||||
// bot.global_command_delete(1395839332220408051);
|
||||
}
|
||||
if (dpp::run_once<struct register_bot_commands>()) {
|
||||
createCommands(event, bot);
|
||||
}
|
||||
});
|
||||
|
||||
// Remove dpp::st_wait if you want it to return execution
|
||||
|
13
src/CommandManagement.cpp
Normal file
13
src/CommandManagement.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "../languages/locale_en.hpp"
|
||||
#include "../token.h"
|
||||
#include "Commands.hpp"
|
||||
#include <dpp/cluster.h>
|
||||
#include <dpp/dispatcher.h>
|
||||
|
||||
void createCommands(const dpp::ready_t &event, dpp::cluster &bot) {
|
||||
bot.global_command_create(
|
||||
dpp::slashcommand("ping", "Ping-pong test", bot.me.id));
|
||||
bot.guild_command_create(
|
||||
dpp::slashcommand("balance", COMMAND_BALANCE_DESCRIPTION, bot.me.id),
|
||||
GUILD);
|
||||
}
|
@@ -1,7 +1,11 @@
|
||||
#include <dpp/dispatcher.h>
|
||||
|
||||
void createCommands(const dpp::ready_t &event, dpp::cluster &bot);
|
||||
void commandPing(const dpp::slashcommand_t &event);
|
||||
void commandBalance(const dpp::slashcommand_t &event);
|
||||
|
||||
inline std::unordered_map<std::string,
|
||||
std::function<void(const dpp::slashcommand_t &event)>>
|
||||
Commands{{"ping", commandPing}, {"balance", commandBalance}};
|
||||
Commands{{"ping", commandPing},
|
||||
{"balance", commandBalance},
|
||||
{"bal", commandBalance}};
|
||||
|
Reference in New Issue
Block a user