aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2023-03-27 11:53:41 -0400
committerCara Salter <cara@devcara.com>2023-03-27 11:53:41 -0400
commitc8befe7c95b18869f995c4f2cbc2f4cf9c91924f (patch)
treede1c309c0119ea2b101c65b2b040956873e2b48b /src/main.cpp
download142bot-c8befe7c95b18869f995c4f2cbc2f4cf9c91924f.tar.gz
142bot-c8befe7c95b18869f995c4f2cbc2f4cf9c91924f.zip
initial commit
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..6cdbd31
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,32 @@
+#include <dpp/dpp.h>
+#include "include/json.hpp"
+
+using namespace std;
+
+using json = nlohmann::json;
+
+int main(int argc, char const *argv[]) {
+ std::ifstream f("config.json");
+ json cfg = json::parse(f);
+ string token = cfg.value("token", "bad-token");
+
+ dpp::cluster bot(token, dpp::intents::i_all_intents);
+
+ bot.on_log(dpp::utility::cout_logger());
+ /* code */
+
+ bot.on_slashcommand([](const dpp::slashcommand_t &event) {
+ if (event.command.get_command_name() == "ping") {
+ event.reply("Pong!");
+ }
+ });
+
+ 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!", bot.me.id));
+ }
+ });
+
+ bot.start(dpp::st_wait);
+ return 0;
+}