-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
66 lines (55 loc) · 2.33 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <dpp/dpp.h>
#include "src/commands/include/PingCommand.h"
#include "src/commands/include/HelpCommand.h"
#include "src/commands/include/TeamCommand.h"
#include "src/commands/include/MatchCommand.h"
#include "src/commands/include/PlayerCommand.h"
#include "src/commands/include/ScheduleCommand.h"
#include "src/include/Utilities.h"
int main() {
SQLite::Database db("rocket_league.db", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
Player::table_init(db);
Game::table_init(db);
Team::table_init(db);
Match::table_init(db);
dpp::cluster bot(Utilities::getBotToken(), dpp::intents::i_all_intents);
bot.on_log(dpp::utility::cout_logger());
bot.on_slashcommand([&bot](const dpp::slashcommand_t& event) {
dpp::interaction interaction = event.command;
dpp::command_interaction cmd_data = interaction.get_command_interaction();
if (interaction.get_command_name() == "ping") {
event.reply(PingCommand::msg(event, bot));
}
else if (interaction.get_command_name() == "help"){
event.reply(HelpCommand::msg(event, bot));
}
else if (interaction.get_command_name() == "match"){
event.reply(MatchCommand::msg(event, bot));
}
else if (interaction.get_command_name() == "team"){
event.reply(TeamCommand::msg(event, bot));
}
else if (interaction.get_command_name() == "schedule"){
event.reply(ScheduleCommand::msg(event, bot));
}
else if (interaction.get_command_name() == "player"){
event.reply(PlayerCommand::msg(event, bot));
}
});
bot.on_ready([&bot](const dpp::ready_t& event) {
if (dpp::run_once<struct register_bot_commands>()) {
vector<dpp::slashcommand> CommandGroup = {
PingCommand::cmd(bot.me.id),
HelpCommand::cmd(bot.me.id),
MatchCommand::cmd(bot.me.id),
TeamCommand::cmd(bot.me.id),
ScheduleCommand::cmd(bot.me.id),
PlayerCommand::cmd(bot.me.id)
};
bot.global_bulk_command_create(CommandGroup, [](const dpp::confirmation_callback_t& result){
Utilities::cmd_init(std::get<dpp::slashcommand_map>(result.value));
});
}
});
bot.start(dpp::st_wait);
}