From 7b421194df7a2af7024e890c3b76d741ea3ae647 Mon Sep 17 00:00:00 2001 From: Archie Jaskowicz Date: Mon, 11 Dec 2023 19:48:53 +0000 Subject: [PATCH 1/2] feat: template now uses coro --- mac-example-bot.xcodeproj/project.pbxproj | 30 ++++++++++++++++++----- mac-example-bot/main.cpp | 8 +++--- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/mac-example-bot.xcodeproj/project.pbxproj b/mac-example-bot.xcodeproj/project.pbxproj index 56b4535..51d822a 100644 --- a/mac-example-bot.xcodeproj/project.pbxproj +++ b/mac-example-bot.xcodeproj/project.pbxproj @@ -253,10 +253,19 @@ DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ""; - HEADER_SEARCH_PATHS = /opt/homebrew/include; - LIBRARY_SEARCH_PATHS = /opt/homebrew/lib; + HEADER_SEARCH_PATHS = ( + /opt/homebrew/include, + /usr/local/include, + ); + LIBRARY_SEARCH_PATHS = ( + /opt/homebrew/lib, + /usr/local/lib, + ); OTHER_CFLAGS = ""; - OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; + OTHER_CPLUSPLUSFLAGS = ( + "$(OTHER_CFLAGS)", + "-DDPP_CORO", + ); OTHER_LDFLAGS = "-ldpp"; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -272,10 +281,19 @@ DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ""; - HEADER_SEARCH_PATHS = /opt/homebrew/include; - LIBRARY_SEARCH_PATHS = /opt/homebrew/lib; + HEADER_SEARCH_PATHS = ( + /opt/homebrew/include, + /usr/local/include, + ); + LIBRARY_SEARCH_PATHS = ( + /opt/homebrew/lib, + /usr/local/lib, + ); OTHER_CFLAGS = ""; - OTHER_CPLUSPLUSFLAGS = "$(OTHER_CFLAGS)"; + OTHER_CPLUSPLUSFLAGS = ( + "$(OTHER_CFLAGS)", + "-DDPP_CORO", + ); OTHER_LDFLAGS = "-ldpp"; PRODUCT_NAME = "$(TARGET_NAME)"; }; diff --git a/mac-example-bot/main.cpp b/mac-example-bot/main.cpp index 28d6518..a20e143 100644 --- a/mac-example-bot/main.cpp +++ b/mac-example-bot/main.cpp @@ -1,5 +1,6 @@ #include #include +#include /* Be sure to place your token in the line below. * Follow steps here to get a token: @@ -17,11 +18,12 @@ int main() { /* Output simple log messages to stdout */ bot.on_log(dpp::utility::cout_logger()); - /* Handle slash command */ - bot.on_slashcommand([](const dpp::slashcommand_t& event) { + /* Handle slash command with the most recent addition to D++ features, coroutines! */ + bot.on_slashcommand([](const dpp::slashcommand_t& event) -> dpp::task { if (event.command.get_command_name() == "ping") { - event.reply("Pong!"); + co_await event.co_reply("Pong!"); } + co_return; }); /* Register slash command here in on_ready */ From b65b112b8cebab437fa2331dcfc70f71c3e5c79d Mon Sep 17 00:00:00 2001 From: Archie Jaskowicz Date: Mon, 11 Dec 2023 19:50:21 +0000 Subject: [PATCH 2/2] fix: removed json include --- mac-example-bot/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/mac-example-bot/main.cpp b/mac-example-bot/main.cpp index a20e143..2b3652a 100644 --- a/mac-example-bot/main.cpp +++ b/mac-example-bot/main.cpp @@ -1,6 +1,5 @@ #include #include -#include /* Be sure to place your token in the line below. * Follow steps here to get a token: