diff --git a/buildtools/classes/Generator/CoroGenerator.php b/buildtools/classes/Generator/CoroGenerator.php index e3ce67bb8a..faf0d41c72 100644 --- a/buildtools/classes/Generator/CoroGenerator.php +++ b/buildtools/classes/Generator/CoroGenerator.php @@ -54,6 +54,7 @@ public function generateHeaderStart(): string public function generateCppStart(): string { return $this->generateHeaderStart() . << #include @@ -80,6 +81,7 @@ public function checkForChanges(): bool } echo "-- Autogenerating include/dpp/cluster_coro_calls.h\n"; + echo "-- Autogenerating src/dpp/cluster_coro_calls.cpp\n"; return true; } @@ -88,11 +90,7 @@ public function checkForChanges(): bool */ public function generateHeaderDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterTypes, string $parameterNames): string { - $parameterNames = preg_replace('/^, /', '', $parameterNames); - if (!empty($parameterNames)) { - $parameterNames .= ', '; - } - return "auto inline co_{$currentFunction}($noDefaults) {\n\treturn dpp::awaitable(this, [&] (auto cc) { this->$currentFunction({$parameterNames}cc); }); \n}\n\n"; + return "awaitable co_{$currentFunction}($parameters);\n\n"; } /** @@ -100,7 +98,7 @@ public function generateHeaderDef(string $returnType, string $currentFunction, s */ public function generateCppDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterTypes, string $parameterNames): string { - return ''; + return "awaitable cluster::co_${currentFunction}($noDefaults) {\n\treturn {this, static_cast(&cluster::$currentFunction)$parameterNames};\n}\n\n"; } /** @@ -116,7 +114,7 @@ public function getCommentArray(): array */ public function saveHeader(string $content): void { - $content .= "auto inline co_request(const std::string &url, http_method method, const std::string &postdata = \"\", const std::string &mimetype = \"text/plain\", const std::multimap &headers = {}) {\n\treturn dpp::awaitable(this, [&] (auto cc) { this->request(url, method, cc, mimetype, headers); }); \n}\n\n"; + $content .= "awaitable co_request(const std::string &url, http_method method, const std::string &postdata = \"\", const std::string &mimetype = \"text/plain\", const std::multimap &headers = {});\n\n"; file_put_contents('include/dpp/cluster_coro_calls.h', $content); } @@ -125,7 +123,11 @@ public function saveHeader(string $content): void */ public function saveCpp(string $cppcontent): void { - /* No cpp file to save, code is all inline */ + $cppcontent .= "dpp::awaitable dpp::cluster::co_request(const std::string &url, http_method method, const std::string &postdata, const std::string &mimetype, const std::multimap &headers) {\n\treturn awaitable{[&](auto &&cc) { this->request(url, method, cc, postdata, mimetype, headers); }};\n} + +#endif +"; + file_put_contents('src/dpp/cluster_coro_calls.cpp', $cppcontent); } } diff --git a/include/dpp/cluster_coro_calls.h b/include/dpp/cluster_coro_calls.h index d7ed89b80a..e7d0567512 100644 --- a/include/dpp/cluster_coro_calls.h +++ b/include/dpp/cluster_coro_calls.h @@ -38,9 +38,7 @@ * @return slashcommand_map returned object on completion * \memberof dpp::cluster */ -auto inline co_global_bulk_command_create(const std::vector &commands) { - return dpp::awaitable(this, [&] (auto cc) { this->global_bulk_command_create(commands, cc); }); -} +awaitable co_global_bulk_command_create(const std::vector &commands); /** * @brief Create a global slash command (a bot can have a maximum of 100 of these). @@ -51,9 +49,7 @@ auto inline co_global_bulk_command_create(const std::vector &comma * @return slashcommand returned object on completion * \memberof dpp::cluster */ -auto inline co_global_command_create(const slashcommand &s) { - return dpp::awaitable(this, [&] (auto cc) { this->global_command_create(s, cc); }); -} +awaitable co_global_command_create(const slashcommand &s); /** * @brief Get a global slash command @@ -64,9 +60,7 @@ auto inline co_global_command_create(const slashcommand &s) { * @return slashcommand returned object on completion * \memberof dpp::cluster */ -auto inline co_global_command_get(snowflake id) { - return dpp::awaitable(this, [&] (auto cc) { this->global_command_get(id, cc); }); -} +awaitable co_global_command_get(snowflake id); /** * @brief Delete a global slash command (a bot can have a maximum of 100 of these) @@ -77,9 +71,7 @@ auto inline co_global_command_get(snowflake id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_global_command_delete(snowflake id) { - return dpp::awaitable(this, [&] (auto cc) { this->global_command_delete(id, cc); }); -} +awaitable co_global_command_delete(snowflake id); /** * @brief Edit a global slash command (a bot can have a maximum of 100 of these) @@ -90,9 +82,7 @@ auto inline co_global_command_delete(snowflake id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_global_command_edit(const slashcommand &s) { - return dpp::awaitable(this, [&] (auto cc) { this->global_command_edit(s, cc); }); -} +awaitable co_global_command_edit(const slashcommand &s); /** * @brief Get the application's global slash commands @@ -102,9 +92,7 @@ auto inline co_global_command_edit(const slashcommand &s) { * @return slashcommand_map returned object on completion * \memberof dpp::cluster */ -auto inline co_global_commands_get() { - return dpp::awaitable(this, [&] (auto cc) { this->global_commands_get(cc); }); -} +awaitable co_global_commands_get(); /** * @brief Create/overwrite guild slash commands. @@ -118,9 +106,7 @@ auto inline co_global_commands_get() { * @return slashcommand_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_bulk_command_create(const std::vector &commands, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_bulk_command_create(commands, guild_id, cc); }); -} +awaitable co_guild_bulk_command_create(const std::vector &commands, snowflake guild_id); /** * @brief Get all slash command permissions of a guild @@ -131,9 +117,7 @@ auto inline co_guild_bulk_command_create(const std::vector &comman * @return guild_command_permissions_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_commands_get_permissions(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_commands_get_permissions(guild_id, cc); }); -} +awaitable co_guild_commands_get_permissions(snowflake guild_id); /** * @brief Edit/Overwrite the permissions of all existing slash commands in a guild @@ -149,9 +133,7 @@ auto inline co_guild_commands_get_permissions(snowflake guild_id) { * @deprecated This has been disabled with updates to Permissions v2. You can use guild_command_edit_permissions instead * \memberof dpp::cluster */ -auto inline co_guild_bulk_command_edit_permissions(const std::vector &commands, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_bulk_command_edit_permissions(commands, guild_id, cc); }); -} +awaitable co_guild_bulk_command_edit_permissions(const std::vector &commands, snowflake guild_id); /** * @brief Create a slash command local to a guild @@ -164,9 +146,7 @@ auto inline co_guild_bulk_command_edit_permissions(const std::vectorguild_command_create(s, guild_id, cc); }); -} +awaitable co_guild_command_create(const slashcommand &s, snowflake guild_id); /** * @brief Delete a slash command local to a guild @@ -178,9 +158,7 @@ auto inline co_guild_command_create(const slashcommand &s, snowflake guild_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_command_delete(snowflake id, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_command_delete(id, guild_id, cc); }); -} +awaitable co_guild_command_delete(snowflake id, snowflake guild_id); /** * @brief Edit slash command permissions of a guild @@ -193,9 +171,7 @@ auto inline co_guild_command_delete(snowflake id, snowflake guild_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_command_edit_permissions(const slashcommand &s, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_command_edit_permissions(s, guild_id, cc); }); -} +awaitable co_guild_command_edit_permissions(const slashcommand &s, snowflake guild_id); /** * @brief Get a slash command of a guild @@ -208,9 +184,7 @@ auto inline co_guild_command_edit_permissions(const slashcommand &s, snowflake g * @return slashcommand returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_command_get(snowflake id, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_command_get(id, guild_id, cc); }); -} +awaitable co_guild_command_get(snowflake id, snowflake guild_id); /** * @brief Get the permissions for a slash command of a guild @@ -222,9 +196,7 @@ auto inline co_guild_command_get(snowflake id, snowflake guild_id) { * @return guild_command_permissions returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_command_get_permissions(snowflake id, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_command_get_permissions(id, guild_id, cc); }); -} +awaitable co_guild_command_get_permissions(snowflake id, snowflake guild_id); /** * @brief Edit a slash command local to a guild @@ -236,9 +208,7 @@ auto inline co_guild_command_get_permissions(snowflake id, snowflake guild_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_command_edit(const slashcommand &s, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_command_edit(s, guild_id, cc); }); -} +awaitable co_guild_command_edit(const slashcommand &s, snowflake guild_id); /** * @brief Get the application's slash commands for a guild @@ -250,9 +220,7 @@ auto inline co_guild_command_edit(const slashcommand &s, snowflake guild_id) { * @return slashcommand_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_commands_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_commands_get(guild_id, cc); }); -} +awaitable co_guild_commands_get(snowflake guild_id); /** * @brief Respond to a slash command @@ -265,9 +233,7 @@ auto inline co_guild_commands_get(snowflake guild_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_interaction_response_create(snowflake interaction_id, const std::string &token, const interaction_response &r) { - return dpp::awaitable(this, [&] (auto cc) { this->interaction_response_create(interaction_id, token, r, cc); }); -} +awaitable co_interaction_response_create(snowflake interaction_id, const std::string &token, const interaction_response &r); /** * @brief Edit response to a slash command @@ -279,9 +245,7 @@ auto inline co_interaction_response_create(snowflake interaction_id, const std:: * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_interaction_response_edit(const std::string &token, const message &m) { - return dpp::awaitable(this, [&] (auto cc) { this->interaction_response_edit(token, m, cc); }); -} +awaitable co_interaction_response_edit(const std::string &token, const message &m); /** * @brief Create a followup message to a slash command @@ -293,9 +257,7 @@ auto inline co_interaction_response_edit(const std::string &token, const message * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_interaction_followup_create(const std::string &token, const message &m) { - return dpp::awaitable(this, [&] (auto cc) { this->interaction_followup_create(token, m, cc); }); -} +awaitable co_interaction_followup_create(const std::string &token, const message &m); /** * @brief Edit original followup message to a slash command @@ -308,9 +270,7 @@ auto inline co_interaction_followup_create(const std::string &token, const messa * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_interaction_followup_edit_original(const std::string &token, const message &m) { - return dpp::awaitable(this, [&] (auto cc) { this->interaction_followup_edit_original(token, m, cc); }); -} +awaitable co_interaction_followup_edit_original(const std::string &token, const message &m); /** * @brief Delete the initial interaction response @@ -321,9 +281,7 @@ auto inline co_interaction_followup_edit_original(const std::string &token, cons * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_interaction_followup_delete(const std::string &token) { - return dpp::awaitable(this, [&] (auto cc) { this->interaction_followup_delete(token, cc); }); -} +awaitable co_interaction_followup_delete(const std::string &token); /** * @brief Edit followup message to a slash command @@ -336,9 +294,7 @@ auto inline co_interaction_followup_delete(const std::string &token) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_interaction_followup_edit(const std::string &token, const message &m) { - return dpp::awaitable(this, [&] (auto cc) { this->interaction_followup_edit(token, m, cc); }); -} +awaitable co_interaction_followup_edit(const std::string &token, const message &m); /** * @brief Get the followup message to a slash command @@ -350,9 +306,7 @@ auto inline co_interaction_followup_edit(const std::string &token, const message * @return message returned object on completion * \memberof dpp::cluster */ -auto inline co_interaction_followup_get(const std::string &token, snowflake message_id) { - return dpp::awaitable(this, [&] (auto cc) { this->interaction_followup_get(token, message_id, cc); }); -} +awaitable co_interaction_followup_get(const std::string &token, snowflake message_id); /** * @brief Get all auto moderation rules for a guild @@ -361,9 +315,7 @@ auto inline co_interaction_followup_get(const std::string &token, snowflake mess * @return automod_rule_map returned object on completion * \memberof dpp::cluster */ -auto inline co_automod_rules_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->automod_rules_get(guild_id, cc); }); -} +awaitable co_automod_rules_get(snowflake guild_id); /** * @brief Get a single auto moderation rule @@ -373,9 +325,7 @@ auto inline co_automod_rules_get(snowflake guild_id) { * @return automod_rule returned object on completion * \memberof dpp::cluster */ -auto inline co_automod_rule_get(snowflake guild_id, snowflake rule_id) { - return dpp::awaitable(this, [&] (auto cc) { this->automod_rule_get(guild_id, rule_id, cc); }); -} +awaitable co_automod_rule_get(snowflake guild_id, snowflake rule_id); /** * @brief Create an auto moderation rule @@ -385,9 +335,7 @@ auto inline co_automod_rule_get(snowflake guild_id, snowflake rule_id) { * @return automod_rule returned object on completion * \memberof dpp::cluster */ -auto inline co_automod_rule_create(snowflake guild_id, const automod_rule& r) { - return dpp::awaitable(this, [&] (auto cc) { this->automod_rule_create(guild_id, r, cc); }); -} +awaitable co_automod_rule_create(snowflake guild_id, const automod_rule& r); /** * @brief Edit an auto moderation rule @@ -397,9 +345,7 @@ auto inline co_automod_rule_create(snowflake guild_id, const automod_rule& r) { * @return automod_rule returned object on completion * \memberof dpp::cluster */ -auto inline co_automod_rule_edit(snowflake guild_id, const automod_rule& r) { - return dpp::awaitable(this, [&] (auto cc) { this->automod_rule_edit(guild_id, r, cc); }); -} +awaitable co_automod_rule_edit(snowflake guild_id, const automod_rule& r); /** * @brief Delete an auto moderation rule @@ -409,9 +355,7 @@ auto inline co_automod_rule_edit(snowflake guild_id, const automod_rule& r) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_automod_rule_delete(snowflake guild_id, snowflake rule_id) { - return dpp::awaitable(this, [&] (auto cc) { this->automod_rule_delete(guild_id, rule_id, cc); }); -} +awaitable co_automod_rule_delete(snowflake guild_id, snowflake rule_id); /** * @brief Create a channel @@ -429,9 +373,7 @@ auto inline co_automod_rule_delete(snowflake guild_id, snowflake rule_id) { * @return channel returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_create(const class channel &c) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_create(c, cc); }); -} +awaitable co_channel_create(const class channel &c); /** * @brief Remove a permission from a channel @@ -443,9 +385,7 @@ auto inline co_channel_create(const class channel &c) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_delete_permission(const class channel &c, snowflake overwrite_id) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_delete_permission(c, overwrite_id, cc); }); -} +awaitable co_channel_delete_permission(const class channel &c, snowflake overwrite_id); /** * @brief Delete a channel @@ -456,9 +396,7 @@ auto inline co_channel_delete_permission(const class channel &c, snowflake overw * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_delete(snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_delete(channel_id, cc); }); -} +awaitable co_channel_delete(snowflake channel_id); /** * @brief Edit a channel's permissions @@ -474,9 +412,7 @@ auto inline co_channel_delete(snowflake channel_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_edit_permissions(const class channel &c, const snowflake overwrite_id, const uint64_t allow, const uint64_t deny, const bool member) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_edit_permissions(c, overwrite_id, allow, deny, member, cc); }); -} +awaitable co_channel_edit_permissions(const class channel &c, const snowflake overwrite_id, const uint64_t allow, const uint64_t deny, const bool member); /** * @brief Edit a channel's permissions @@ -492,9 +428,7 @@ auto inline co_channel_edit_permissions(const class channel &c, const snowflake * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_edit_permissions(const snowflake channel_id, const snowflake overwrite_id, const uint64_t allow, const uint64_t deny, const bool member) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_edit_permissions(channel_id, overwrite_id, allow, deny, member, cc); }); -} +awaitable co_channel_edit_permissions(const snowflake channel_id, const snowflake overwrite_id, const uint64_t allow, const uint64_t deny, const bool member); /** * @brief Edit multiple channels positions @@ -509,9 +443,7 @@ auto inline co_channel_edit_permissions(const snowflake channel_id, const snowfl * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_edit_positions(const std::vector &c) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_edit_positions(c, cc); }); -} +awaitable co_channel_edit_positions(const std::vector &c); /** * @brief Edit a channel @@ -522,9 +454,7 @@ auto inline co_channel_edit_positions(const std::vector &c) { * @return channel returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_edit(const class channel &c) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_edit(c, cc); }); -} +awaitable co_channel_edit(const class channel &c); /** * @brief Follow an announcement (news) channel @@ -535,9 +465,7 @@ auto inline co_channel_edit(const class channel &c) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_follow_news(const class channel &c, snowflake target_channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_follow_news(c, target_channel_id, cc); }); -} +awaitable co_channel_follow_news(const class channel &c, snowflake target_channel_id); /** * @brief Get a channel @@ -548,9 +476,7 @@ auto inline co_channel_follow_news(const class channel &c, snowflake target_chan * @return channel returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_get(snowflake c) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_get(c, cc); }); -} +awaitable co_channel_get(snowflake c); /** * @brief Create invite for a channel @@ -562,9 +488,7 @@ auto inline co_channel_get(snowflake c) { * @return invite returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_invite_create(const class channel &c, const class invite &i) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_invite_create(c, i, cc); }); -} +awaitable co_channel_invite_create(const class channel &c, const class invite &i); /** * @brief Get invites for a channel @@ -575,9 +499,7 @@ auto inline co_channel_invite_create(const class channel &c, const class invite * @return invite_map returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_invites_get(const class channel &c) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_invites_get(c, cc); }); -} +awaitable co_channel_invites_get(const class channel &c); /** * @brief Trigger channel typing indicator @@ -587,9 +509,7 @@ auto inline co_channel_invites_get(const class channel &c) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_typing(const class channel &c) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_typing(c, cc); }); -} +awaitable co_channel_typing(const class channel &c); /** * @brief Trigger channel typing indicator @@ -599,9 +519,7 @@ auto inline co_channel_typing(const class channel &c) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_typing(snowflake cid) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_typing(cid, cc); }); -} +awaitable co_channel_typing(snowflake cid); /** * @brief Get all channels for a guild @@ -612,9 +530,7 @@ auto inline co_channel_typing(snowflake cid) { * @return channel_map returned object on completion * \memberof dpp::cluster */ -auto inline co_channels_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->channels_get(guild_id, cc); }); -} +awaitable co_channels_get(snowflake guild_id); /** * @brief Create a dm channel @@ -624,9 +540,7 @@ auto inline co_channels_get(snowflake guild_id) { * @return channel returned object on completion * \memberof dpp::cluster */ -auto inline co_create_dm_channel(snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->create_dm_channel(user_id, cc); }); -} +awaitable co_create_dm_channel(snowflake user_id); /** * @brief Get current user DM channels @@ -634,9 +548,7 @@ auto inline co_create_dm_channel(snowflake user_id) { * @return channel_map returned object on completion * \memberof dpp::cluster */ -auto inline co_current_user_get_dms() { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_get_dms(cc); }); -} +awaitable co_current_user_get_dms(); /** * @brief Create a direct message, also create the channel for the direct message if needed @@ -650,9 +562,7 @@ auto inline co_current_user_get_dms() { * @return message returned object on completion * \memberof dpp::cluster */ -auto inline co_direct_message_create(snowflake user_id, const message &m) { - return dpp::awaitable(this, [&] (auto cc) { this->direct_message_create(user_id, m, cc); }); -} +awaitable co_direct_message_create(snowflake user_id, const message &m); /** * @brief Adds a recipient to a Group DM using their access token @@ -665,9 +575,7 @@ auto inline co_direct_message_create(snowflake user_id, const message &m) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_gdm_add(snowflake channel_id, snowflake user_id, const std::string &access_token, const std::string &nick) { - return dpp::awaitable(this, [&] (auto cc) { this->gdm_add(channel_id, user_id, access_token, nick, cc); }); -} +awaitable co_gdm_add(snowflake channel_id, snowflake user_id, const std::string &access_token, const std::string &nick); /** * @brief Removes a recipient from a Group DM @@ -678,9 +586,7 @@ auto inline co_gdm_add(snowflake channel_id, snowflake user_id, const std::strin * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_gdm_remove(snowflake channel_id, snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->gdm_remove(channel_id, user_id, cc); }); -} +awaitable co_gdm_remove(snowflake channel_id, snowflake user_id); /** * @brief Create single emoji. @@ -694,9 +600,7 @@ auto inline co_gdm_remove(snowflake channel_id, snowflake user_id) { * @return emoji returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_emoji_create(snowflake guild_id, const class emoji& newemoji) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_emoji_create(guild_id, newemoji, cc); }); -} +awaitable co_guild_emoji_create(snowflake guild_id, const class emoji& newemoji); /** * @brief Delete a guild emoji @@ -709,9 +613,7 @@ auto inline co_guild_emoji_create(snowflake guild_id, const class emoji& newemoj * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_emoji_delete(snowflake guild_id, snowflake emoji_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_emoji_delete(guild_id, emoji_id, cc); }); -} +awaitable co_guild_emoji_delete(snowflake guild_id, snowflake emoji_id); /** * @brief Edit a single emoji. @@ -725,9 +627,7 @@ auto inline co_guild_emoji_delete(snowflake guild_id, snowflake emoji_id) { * @return emoji returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_emoji_edit(snowflake guild_id, const class emoji& newemoji) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_emoji_edit(guild_id, newemoji, cc); }); -} +awaitable co_guild_emoji_edit(snowflake guild_id, const class emoji& newemoji); /** * @brief Get a single emoji @@ -739,9 +639,7 @@ auto inline co_guild_emoji_edit(snowflake guild_id, const class emoji& newemoji) * @return emoji returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_emoji_get(snowflake guild_id, snowflake emoji_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_emoji_get(guild_id, emoji_id, cc); }); -} +awaitable co_guild_emoji_get(snowflake guild_id, snowflake emoji_id); /** * @brief Get all emojis for a guild @@ -752,9 +650,7 @@ auto inline co_guild_emoji_get(snowflake guild_id, snowflake emoji_id) { * @return emoji_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_emojis_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_emojis_get(guild_id, cc); }); -} +awaitable co_guild_emojis_get(snowflake guild_id); /** * @brief Get the gateway information for the bot using the token @@ -763,9 +659,7 @@ auto inline co_guild_emojis_get(snowflake guild_id) { * @return gateway returned object on completion * \memberof dpp::cluster */ -auto inline co_get_gateway_bot() { - return dpp::awaitable(this, [&] (auto cc) { this->get_gateway_bot(cc); }); -} +awaitable co_get_gateway_bot(); /** * @brief Modify current member @@ -781,9 +675,7 @@ auto inline co_get_gateway_bot() { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_current_member_edit(snowflake guild_id, const std::string &nickname) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_current_member_edit(guild_id, nickname, cc); }); -} +awaitable co_guild_current_member_edit(snowflake guild_id, const std::string &nickname); /** * @brief Get the audit log for a guild @@ -799,9 +691,7 @@ auto inline co_guild_current_member_edit(snowflake guild_id, const std::string & * @return auditlog returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_auditlog_get(snowflake guild_id, snowflake user_id, uint32_t action_type, snowflake before, snowflake after, uint32_t limit) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_auditlog_get(guild_id, user_id, action_type, before, after, limit, cc); }); -} +awaitable co_guild_auditlog_get(snowflake guild_id, snowflake user_id, uint32_t action_type, snowflake before, snowflake after, uint32_t limit); /** * @brief Add guild ban @@ -817,9 +707,7 @@ auto inline co_guild_auditlog_get(snowflake guild_id, snowflake user_id, uint32_ * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_seconds) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_ban_add(guild_id, user_id, delete_message_seconds, cc); }); -} +awaitable co_guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_seconds = 0); /** * @brief Delete guild ban @@ -834,9 +722,7 @@ auto inline co_guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t del * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_ban_delete(snowflake guild_id, snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_ban_delete(guild_id, user_id, cc); }); -} +awaitable co_guild_ban_delete(snowflake guild_id, snowflake user_id); /** * @brief Create a guild @@ -859,9 +745,7 @@ auto inline co_guild_ban_delete(snowflake guild_id, snowflake user_id) { * @return guild returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_create(const class guild &g) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_create(g, cc); }); -} +awaitable co_guild_create(const class guild &g); /** * @brief Delete a guild @@ -874,9 +758,7 @@ auto inline co_guild_create(const class guild &g) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_delete(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_delete(guild_id, cc); }); -} +awaitable co_guild_delete(snowflake guild_id); /** * @brief Delete guild integration @@ -892,9 +774,7 @@ auto inline co_guild_delete(snowflake guild_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_delete_integration(snowflake guild_id, snowflake integration_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_delete_integration(guild_id, integration_id, cc); }); -} +awaitable co_guild_delete_integration(snowflake guild_id, snowflake integration_id); /** * @brief Edit a guild @@ -909,9 +789,7 @@ auto inline co_guild_delete_integration(snowflake guild_id, snowflake integratio * @return guild returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_edit(const class guild &g) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_edit(g, cc); }); -} +awaitable co_guild_edit(const class guild &g); /** * @brief Edit guild widget @@ -926,9 +804,7 @@ auto inline co_guild_edit(const class guild &g) { * @return guild_widget returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_edit_widget(snowflake guild_id, const class guild_widget &gw) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_edit_widget(guild_id, gw, cc); }); -} +awaitable co_guild_edit_widget(snowflake guild_id, const class guild_widget &gw); /** * @brief Get single guild ban @@ -941,9 +817,7 @@ auto inline co_guild_edit_widget(snowflake guild_id, const class guild_widget &g * @return ban returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_ban(snowflake guild_id, snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_ban(guild_id, user_id, cc); }); -} +awaitable co_guild_get_ban(snowflake guild_id, snowflake user_id); /** * @brief Get guild ban list @@ -959,14 +833,10 @@ auto inline co_guild_get_ban(snowflake guild_id, snowflake user_id) { * @return ban_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_bans(snowflake guild_id, snowflake before, snowflake after, snowflake limit) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_bans(guild_id, before, after, limit, cc); }); -} +awaitable co_guild_get_bans(snowflake guild_id, snowflake before, snowflake after, snowflake limit); -auto inline co_guild_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get(guild_id, cc); }); -} +awaitable co_guild_get(snowflake guild_id); /** * @brief Get guild integrations @@ -981,14 +851,10 @@ auto inline co_guild_get(snowflake guild_id) { * @note This endpoint returns a maximum of 50 integrations. If a guild has more integrations, they cannot be accessed. * \memberof dpp::cluster */ -auto inline co_guild_get_integrations(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_integrations(guild_id, cc); }); -} +awaitable co_guild_get_integrations(snowflake guild_id); -auto inline co_guild_get_preview(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_preview(guild_id, cc); }); -} +awaitable co_guild_get_preview(snowflake guild_id); /** * @brief Get guild vanity url, if enabled @@ -1000,9 +866,7 @@ auto inline co_guild_get_preview(snowflake guild_id) { * @return invite returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_vanity(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_vanity(guild_id, cc); }); -} +awaitable co_guild_get_vanity(snowflake guild_id); /** * @brief Get guild widget @@ -1015,9 +879,7 @@ auto inline co_guild_get_vanity(snowflake guild_id) { * @return guild_widget returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_widget(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_widget(guild_id, cc); }); -} +awaitable co_guild_get_widget(snowflake guild_id); /** * @brief Modify guild integration @@ -1030,9 +892,7 @@ auto inline co_guild_get_widget(snowflake guild_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_modify_integration(snowflake guild_id, const class integration &i) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_modify_integration(guild_id, i, cc); }); -} +awaitable co_guild_modify_integration(snowflake guild_id, const class integration &i); /** * @brief Get prune counts @@ -1049,9 +909,7 @@ auto inline co_guild_modify_integration(snowflake guild_id, const class integrat * @return prune returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_prune_counts(snowflake guild_id, const struct prune& pruneinfo) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_prune_counts(guild_id, pruneinfo, cc); }); -} +awaitable co_guild_get_prune_counts(snowflake guild_id, const struct prune& pruneinfo); /** * @brief Begin guild prune @@ -1070,9 +928,7 @@ auto inline co_guild_get_prune_counts(snowflake guild_id, const struct prune& pr * @return prune returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_begin_prune(snowflake guild_id, const struct prune& pruneinfo) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_begin_prune(guild_id, pruneinfo, cc); }); -} +awaitable co_guild_begin_prune(snowflake guild_id, const struct prune& pruneinfo); /** * @brief Change current user nickname @@ -1089,9 +945,7 @@ auto inline co_guild_begin_prune(snowflake guild_id, const struct prune& prunein * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_set_nickname(snowflake guild_id, const std::string &nickname) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_set_nickname(guild_id, nickname, cc); }); -} +awaitable co_guild_set_nickname(snowflake guild_id, const std::string &nickname); /** * @brief Sync guild integration @@ -1103,9 +957,7 @@ auto inline co_guild_set_nickname(snowflake guild_id, const std::string &nicknam * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_sync_integration(snowflake guild_id, snowflake integration_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_sync_integration(guild_id, integration_id, cc); }); -} +awaitable co_guild_sync_integration(snowflake guild_id, snowflake integration_id); /** * @brief Add guild member. Needs a specific oauth2 scope, from which you get the access_token. @@ -1125,9 +977,7 @@ auto inline co_guild_sync_integration(snowflake guild_id, snowflake integration_ * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_add_member(const guild_member& gm, const std::string &access_token) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_add_member(gm, access_token, cc); }); -} +awaitable co_guild_add_member(const guild_member& gm, const std::string &access_token); /** * @brief Edit the properties of an existing guild member @@ -1143,9 +993,7 @@ auto inline co_guild_add_member(const guild_member& gm, const std::string &acces * @return guild_member returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_edit_member(const guild_member& gm) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_edit_member(gm, cc); }); -} +awaitable co_guild_edit_member(const guild_member& gm); /** * @brief Get a guild member @@ -1156,9 +1004,7 @@ auto inline co_guild_edit_member(const guild_member& gm) { * @return guild_member returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_member(snowflake guild_id, snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_member(guild_id, user_id, cc); }); -} +awaitable co_guild_get_member(snowflake guild_id, snowflake user_id); /** * @brief Get all guild members @@ -1172,9 +1018,7 @@ auto inline co_guild_get_member(snowflake guild_id, snowflake user_id) { * @return guild_member_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_members(snowflake guild_id, uint16_t limit, snowflake after) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_members(guild_id, limit, after, cc); }); -} +awaitable co_guild_get_members(snowflake guild_id, uint16_t limit, snowflake after); /** * @brief Add role to guild member @@ -1190,9 +1034,7 @@ auto inline co_guild_get_members(snowflake guild_id, uint16_t limit, snowflake a * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_member_add_role(snowflake guild_id, snowflake user_id, snowflake role_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_member_add_role(guild_id, user_id, role_id, cc); }); -} +awaitable co_guild_member_add_role(snowflake guild_id, snowflake user_id, snowflake role_id); /** * @brief Remove (kick) a guild member @@ -1208,9 +1050,7 @@ auto inline co_guild_member_add_role(snowflake guild_id, snowflake user_id, snow * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_member_delete(snowflake guild_id, snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_member_delete(guild_id, user_id, cc); }); -} +awaitable co_guild_member_delete(snowflake guild_id, snowflake user_id); /** * @brief Remove (kick) a guild member @@ -1225,9 +1065,7 @@ auto inline co_guild_member_delete(snowflake guild_id, snowflake user_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_member_kick(snowflake guild_id, snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_member_kick(guild_id, user_id, cc); }); -} +awaitable co_guild_member_kick(snowflake guild_id, snowflake user_id); /** * @brief Set the timeout of a guild member @@ -1242,9 +1080,7 @@ auto inline co_guild_member_kick(snowflake guild_id, snowflake user_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_member_timeout(snowflake guild_id, snowflake user_id, time_t communication_disabled_until) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_member_timeout(guild_id, user_id, communication_disabled_until, cc); }); -} +awaitable co_guild_member_timeout(snowflake guild_id, snowflake user_id, time_t communication_disabled_until); /** * @brief Remove role from guild member @@ -1261,9 +1097,7 @@ auto inline co_guild_member_timeout(snowflake guild_id, snowflake user_id, time_ * @deprecated Use dpp::cluster::guild_member_remove_role instead * \memberof dpp::cluster */ -auto inline co_guild_member_delete_role(snowflake guild_id, snowflake user_id, snowflake role_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_member_delete_role(guild_id, user_id, role_id, cc); }); -} +awaitable co_guild_member_delete_role(snowflake guild_id, snowflake user_id, snowflake role_id); /** * @brief Remove role from guild member @@ -1279,9 +1113,7 @@ auto inline co_guild_member_delete_role(snowflake guild_id, snowflake user_id, s * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_member_remove_role(snowflake guild_id, snowflake user_id, snowflake role_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_member_remove_role(guild_id, user_id, role_id, cc); }); -} +awaitable co_guild_member_remove_role(snowflake guild_id, snowflake user_id, snowflake role_id); /** * @brief Moves the guild member to a other voice channel, if member is connected to one. @@ -1298,9 +1130,7 @@ auto inline co_guild_member_remove_role(snowflake guild_id, snowflake user_id, s * @return guild_member returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_member_move(const snowflake channel_id, const snowflake guild_id, const snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_member_move(channel_id, guild_id, user_id, cc); }); -} +awaitable co_guild_member_move(const snowflake channel_id, const snowflake guild_id, const snowflake user_id); /** * @brief Search for guild members based on whether their username or nickname starts with the given string. @@ -1314,9 +1144,7 @@ auto inline co_guild_member_move(const snowflake channel_id, const snowflake gui * @return guild_member_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_search_members(snowflake guild_id, const std::string& query, uint16_t limit) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_search_members(guild_id, query, limit, cc); }); -} +awaitable co_guild_search_members(snowflake guild_id, const std::string& query, uint16_t limit); /** * @brief Get guild invites @@ -1329,14 +1157,10 @@ auto inline co_guild_search_members(snowflake guild_id, const std::string& query * @return invite_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_invites(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_invites(guild_id, cc); }); -} +awaitable co_guild_get_invites(snowflake guild_id); -auto inline co_invite_delete(const std::string &invitecode) { - return dpp::awaitable(this, [&] (auto cc) { this->invite_delete(invitecode, cc); }); -} +awaitable co_invite_delete(const std::string &invitecode); /** * @brief Get details about an invite @@ -1347,9 +1171,7 @@ auto inline co_invite_delete(const std::string &invitecode) { * @return invite returned object on completion * \memberof dpp::cluster */ -auto inline co_invite_get(const std::string &invite_code) { - return dpp::awaitable(this, [&] (auto cc) { this->invite_get(invite_code, cc); }); -} +awaitable co_invite_get(const std::string &invite_code); /** * @brief Add a reaction to a message. The reaction string must be either an `emojiname:id` or a unicode character. @@ -1361,9 +1183,7 @@ auto inline co_invite_get(const std::string &invite_code) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_add_reaction(const struct message &m, const std::string &reaction) { - return dpp::awaitable(this, [&] (auto cc) { this->message_add_reaction(m, reaction, cc); }); -} +awaitable co_message_add_reaction(const struct message &m, const std::string &reaction); /** * @brief Add a reaction to a message by id. The reaction string must be either an `emojiname:id` or a unicode character. @@ -1376,9 +1196,7 @@ auto inline co_message_add_reaction(const struct message &m, const std::string & * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_add_reaction(snowflake message_id, snowflake channel_id, const std::string &reaction) { - return dpp::awaitable(this, [&] (auto cc) { this->message_add_reaction(message_id, channel_id, reaction, cc); }); -} +awaitable co_message_add_reaction(snowflake message_id, snowflake channel_id, const std::string &reaction); /** * @brief Send a message to a channel. The callback function is called when the message has been sent @@ -1389,9 +1207,7 @@ auto inline co_message_add_reaction(snowflake message_id, snowflake channel_id, * @return message returned object on completion * \memberof dpp::cluster */ -auto inline co_message_create(const message &m) { - return dpp::awaitable(this, [&] (auto cc) { this->message_create(m, cc); }); -} +awaitable co_message_create(const struct message &m); /** * @brief Crosspost a message. The callback function is called when the message has been sent @@ -1403,9 +1219,7 @@ auto inline co_message_create(const message &m) { * @return message returned object on completion * \memberof dpp::cluster */ -auto inline co_message_crosspost(snowflake message_id, snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->message_crosspost(message_id, channel_id, cc); }); -} +awaitable co_message_crosspost(snowflake message_id, snowflake channel_id); /** * @brief Delete all reactions on a message @@ -1416,9 +1230,7 @@ auto inline co_message_crosspost(snowflake message_id, snowflake channel_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_all_reactions(const struct message &m) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_all_reactions(m, cc); }); -} +awaitable co_message_delete_all_reactions(const struct message &m); /** * @brief Delete all reactions on a message by id @@ -1430,9 +1242,7 @@ auto inline co_message_delete_all_reactions(const struct message &m) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_all_reactions(snowflake message_id, snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_all_reactions(message_id, channel_id, cc); }); -} +awaitable co_message_delete_all_reactions(snowflake message_id, snowflake channel_id); /** * @brief Bulk delete messages from a channel. The callback function is called when the message has been edited @@ -1447,9 +1257,7 @@ auto inline co_message_delete_all_reactions(snowflake message_id, snowflake chan * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_bulk(const std::vector& message_ids, snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_bulk(message_ids, channel_id, cc); }); -} +awaitable co_message_delete_bulk(const std::vector &message_ids, snowflake channel_id); /** * @brief Delete a message from a channel. The callback function is called when the message has been edited @@ -1462,9 +1270,7 @@ auto inline co_message_delete_bulk(const std::vector& message_ids, sn * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete(snowflake message_id, snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete(message_id, channel_id, cc); }); -} +awaitable co_message_delete(snowflake message_id, snowflake channel_id); /** * @brief Delete own reaction from a message. The reaction string must be either an `emojiname:id` or a unicode character. @@ -1476,9 +1282,7 @@ auto inline co_message_delete(snowflake message_id, snowflake channel_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_own_reaction(const struct message &m, const std::string &reaction) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_own_reaction(m, reaction, cc); }); -} +awaitable co_message_delete_own_reaction(const struct message &m, const std::string &reaction); /** * @brief Delete own reaction from a message by id. The reaction string must be either an `emojiname:id` or a unicode character. @@ -1491,9 +1295,7 @@ auto inline co_message_delete_own_reaction(const struct message &m, const std::s * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_own_reaction(snowflake message_id, snowflake channel_id, const std::string &reaction) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_own_reaction(message_id, channel_id, reaction, cc); }); -} +awaitable co_message_delete_own_reaction(snowflake message_id, snowflake channel_id, const std::string &reaction); /** * @brief Delete a user's reaction from a message. The reaction string must be either an `emojiname:id` or a unicode character @@ -1506,9 +1308,7 @@ auto inline co_message_delete_own_reaction(snowflake message_id, snowflake chann * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_reaction(const struct message &m, snowflake user_id, const std::string &reaction) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_reaction(m, user_id, reaction, cc); }); -} +awaitable co_message_delete_reaction(const struct message &m, snowflake user_id, const std::string &reaction); /** * @brief Delete a user's reaction from a message by id. The reaction string must be either an `emojiname:id` or a unicode character @@ -1522,9 +1322,7 @@ auto inline co_message_delete_reaction(const struct message &m, snowflake user_i * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_reaction(snowflake message_id, snowflake channel_id, snowflake user_id, const std::string &reaction) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_reaction(message_id, channel_id, user_id, reaction, cc); }); -} +awaitable co_message_delete_reaction(snowflake message_id, snowflake channel_id, snowflake user_id, const std::string &reaction); /** * @brief Delete all reactions on a message using a particular emoji. The reaction string must be either an `emojiname:id` or a unicode character @@ -1536,9 +1334,7 @@ auto inline co_message_delete_reaction(snowflake message_id, snowflake channel_i * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_reaction_emoji(const struct message &m, const std::string &reaction) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_reaction_emoji(m, reaction, cc); }); -} +awaitable co_message_delete_reaction_emoji(const struct message &m, const std::string &reaction); /** * @brief Delete all reactions on a message using a particular emoji by id. The reaction string must be either an `emojiname:id` or a unicode character @@ -1551,9 +1347,7 @@ auto inline co_message_delete_reaction_emoji(const struct message &m, const std: * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_delete_reaction_emoji(snowflake message_id, snowflake channel_id, const std::string &reaction) { - return dpp::awaitable(this, [&] (auto cc) { this->message_delete_reaction_emoji(message_id, channel_id, reaction, cc); }); -} +awaitable co_message_delete_reaction_emoji(snowflake message_id, snowflake channel_id, const std::string &reaction); /** * @brief Edit a message on a channel. The callback function is called when the message has been edited @@ -1564,9 +1358,7 @@ auto inline co_message_delete_reaction_emoji(snowflake message_id, snowflake cha * @return message returned object on completion * \memberof dpp::cluster */ -auto inline co_message_edit(const message &m) { - return dpp::awaitable(this, [&] (auto cc) { this->message_edit(m, cc); }); -} +awaitable co_message_edit(const struct message &m); /** * @brief Get a message @@ -1578,9 +1370,7 @@ auto inline co_message_edit(const message &m) { * @return message returned object on completion * \memberof dpp::cluster */ -auto inline co_message_get(snowflake message_id, snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->message_get(message_id, channel_id, cc); }); -} +awaitable co_message_get(snowflake message_id, snowflake channel_id); /** * @brief Get reactions on a message for a particular emoji. The reaction string must be either an `emojiname:id` or a unicode character @@ -1595,9 +1385,7 @@ auto inline co_message_get(snowflake message_id, snowflake channel_id) { * @return user_map returned object on completion * \memberof dpp::cluster */ -auto inline co_message_get_reactions(const struct message &m, const std::string &reaction, snowflake before, snowflake after, snowflake limit) { - return dpp::awaitable(this, [&] (auto cc) { this->message_get_reactions(m, reaction, before, after, limit, cc); }); -} +awaitable co_message_get_reactions(const struct message &m, const std::string &reaction, snowflake before, snowflake after, snowflake limit); /** * @brief Get reactions on a message for a particular emoji by id. The reaction string must be either an `emojiname:id` or a unicode character @@ -1613,9 +1401,7 @@ auto inline co_message_get_reactions(const struct message &m, const std::string * @return emoji_map returned object on completion * \memberof dpp::cluster */ -auto inline co_message_get_reactions(snowflake message_id, snowflake channel_id, const std::string &reaction, snowflake before, snowflake after, snowflake limit) { - return dpp::awaitable(this, [&] (auto cc) { this->message_get_reactions(message_id, channel_id, reaction, before, after, limit, cc); }); -} +awaitable co_message_get_reactions(snowflake message_id, snowflake channel_id, const std::string &reaction, snowflake before, snowflake after, snowflake limit); /** * @brief Pin a message @@ -1627,9 +1413,7 @@ auto inline co_message_get_reactions(snowflake message_id, snowflake channel_id, * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_pin(snowflake channel_id, snowflake message_id) { - return dpp::awaitable(this, [&] (auto cc) { this->message_pin(channel_id, message_id, cc); }); -} +awaitable co_message_pin(snowflake channel_id, snowflake message_id); /** * @brief Get multiple messages. @@ -1646,9 +1430,7 @@ auto inline co_message_pin(snowflake channel_id, snowflake message_id) { * @return message_map returned object on completion * \memberof dpp::cluster */ -auto inline co_messages_get(snowflake channel_id, snowflake around, snowflake before, snowflake after, uint64_t limit) { - return dpp::awaitable(this, [&] (auto cc) { this->messages_get(channel_id, around, before, after, limit, cc); }); -} +awaitable co_messages_get(snowflake channel_id, snowflake around, snowflake before, snowflake after, uint64_t limit); /** * @brief Unpin a message @@ -1660,9 +1442,7 @@ auto inline co_messages_get(snowflake channel_id, snowflake around, snowflake be * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_message_unpin(snowflake channel_id, snowflake message_id) { - return dpp::awaitable(this, [&] (auto cc) { this->message_unpin(channel_id, message_id, cc); }); -} +awaitable co_message_unpin(snowflake channel_id, snowflake message_id); /** * @brief Get a channel's pins @@ -1672,9 +1452,7 @@ auto inline co_message_unpin(snowflake channel_id, snowflake message_id) { * @return message_map returned object on completion * \memberof dpp::cluster */ -auto inline co_channel_pins_get(snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->channel_pins_get(channel_id, cc); }); -} +awaitable co_channel_pins_get(snowflake channel_id); /** * @brief Create a role on a guild @@ -1689,9 +1467,7 @@ auto inline co_channel_pins_get(snowflake channel_id) { * @return role returned object on completion * \memberof dpp::cluster */ -auto inline co_role_create(const class role &r) { - return dpp::awaitable(this, [&] (auto cc) { this->role_create(r, cc); }); -} +awaitable co_role_create(const class role &r); /** * @brief Delete a role @@ -1706,9 +1482,7 @@ auto inline co_role_create(const class role &r) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_role_delete(snowflake guild_id, snowflake role_id) { - return dpp::awaitable(this, [&] (auto cc) { this->role_delete(guild_id, role_id, cc); }); -} +awaitable co_role_delete(snowflake guild_id, snowflake role_id); /** * @brief Edit a role on a guild @@ -1722,9 +1496,7 @@ auto inline co_role_delete(snowflake guild_id, snowflake role_id) { * @return role returned object on completion * \memberof dpp::cluster */ -auto inline co_role_edit(const class role &r) { - return dpp::awaitable(this, [&] (auto cc) { this->role_edit(r, cc); }); -} +awaitable co_role_edit(const class role &r); /** * @brief Edit multiple role's position in a guild. Returns a list of all roles of the guild on success. @@ -1740,9 +1512,7 @@ auto inline co_role_edit(const class role &r) { * @return role_map returned object on completion * \memberof dpp::cluster */ -auto inline co_roles_edit_position(snowflake guild_id, const std::vector &roles) { - return dpp::awaitable(this, [&] (auto cc) { this->roles_edit_position(guild_id, roles, cc); }); -} +awaitable co_roles_edit_position(snowflake guild_id, const std::vector &roles); /** * @brief Get a role for a guild @@ -1753,9 +1523,7 @@ auto inline co_roles_edit_position(snowflake guild_id, const std::vector & * @return role_map returned object on completion * \memberof dpp::cluster */ -auto inline co_roles_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->roles_get(guild_id, cc); }); -} +awaitable co_roles_get(snowflake guild_id); /** * @brief Get the application's role connection metadata records @@ -1766,9 +1534,7 @@ auto inline co_roles_get(snowflake guild_id) { * @return application_role_connection returned object on completion * \memberof dpp::cluster */ -auto inline co_application_role_connection_get(snowflake application_id) { - return dpp::awaitable(this, [&] (auto cc) { this->application_role_connection_get(application_id, cc); }); -} +awaitable co_application_role_connection_get(snowflake application_id); /** * @brief Update the application's role connection metadata records @@ -1781,9 +1547,7 @@ auto inline co_application_role_connection_get(snowflake application_id) { * @note An application can have a maximum of 5 metadata records. * \memberof dpp::cluster */ -auto inline co_application_role_connection_update(snowflake application_id, const std::vector &connection_metadata) { - return dpp::awaitable(this, [&] (auto cc) { this->application_role_connection_update(application_id, connection_metadata, cc); }); -} +awaitable co_application_role_connection_update(snowflake application_id, const std::vector &connection_metadata); /** * @brief Get user application role connection @@ -1794,9 +1558,7 @@ auto inline co_application_role_connection_update(snowflake application_id, cons * @return application_role_connection returned object on completion * \memberof dpp::cluster */ -auto inline co_user_application_role_connection_get(snowflake application_id) { - return dpp::awaitable(this, [&] (auto cc) { this->user_application_role_connection_get(application_id, cc); }); -} +awaitable co_user_application_role_connection_get(snowflake application_id); /** * @brief Update user application role connection @@ -1808,9 +1570,7 @@ auto inline co_user_application_role_connection_get(snowflake application_id) { * @return application_role_connection returned object on completion * \memberof dpp::cluster */ -auto inline co_user_application_role_connection_update(snowflake application_id, const application_role_connection &connection) { - return dpp::awaitable(this, [&] (auto cc) { this->user_application_role_connection_update(application_id, connection, cc); }); -} +awaitable co_user_application_role_connection_update(snowflake application_id, const application_role_connection &connection); /** * @brief Get all scheduled events for a guild @@ -1820,9 +1580,7 @@ auto inline co_user_application_role_connection_update(snowflake application_id, * @return scheduled_event_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_events_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_events_get(guild_id, cc); }); -} +awaitable co_guild_events_get(snowflake guild_id); /** * @brief Create a scheduled event on a guild @@ -1833,9 +1591,7 @@ auto inline co_guild_events_get(snowflake guild_id) { * @return scheduled_event returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_event_create(const scheduled_event& event) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_event_create(event, cc); }); -} +awaitable co_guild_event_create(const scheduled_event& event); /** * @brief Delete a scheduled event from a guild @@ -1847,9 +1603,7 @@ auto inline co_guild_event_create(const scheduled_event& event) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_event_delete(snowflake event_id, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_event_delete(event_id, guild_id, cc); }); -} +awaitable co_guild_event_delete(snowflake event_id, snowflake guild_id); /** * @brief Edit/modify a scheduled event on a guild @@ -1860,9 +1614,7 @@ auto inline co_guild_event_delete(snowflake event_id, snowflake guild_id) { * @return scheduled_event returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_event_edit(const scheduled_event& event) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_event_edit(event, cc); }); -} +awaitable co_guild_event_edit(const scheduled_event& event); /** * @brief Get a scheduled event for a guild @@ -1874,14 +1626,10 @@ auto inline co_guild_event_edit(const scheduled_event& event) { * @return scheduled_event returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_event_get(snowflake guild_id, snowflake event_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_event_get(guild_id, event_id, cc); }); -} +awaitable co_guild_event_get(snowflake guild_id, snowflake event_id); -auto inline co_stage_instance_create(const stage_instance& si) { - return dpp::awaitable(this, [&] (auto cc) { this->stage_instance_create(si, cc); }); -} +awaitable co_stage_instance_create(const stage_instance& si); /** * @brief Get the stage instance associated with the channel id, if it exists. @@ -1891,14 +1639,10 @@ auto inline co_stage_instance_create(const stage_instance& si) { * @return stage_instance returned object on completion * \memberof dpp::cluster */ -auto inline co_stage_instance_get(const snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->stage_instance_get(channel_id, cc); }); -} +awaitable co_stage_instance_get(const snowflake channel_id); -auto inline co_stage_instance_edit(const stage_instance& si) { - return dpp::awaitable(this, [&] (auto cc) { this->stage_instance_edit(si, cc); }); -} +awaitable co_stage_instance_edit(const stage_instance& si); /** * @brief Delete a stage instance. @@ -1909,9 +1653,7 @@ auto inline co_stage_instance_edit(const stage_instance& si) { * @note This method supports audit log reasons set by the cluster::set_audit_reason() method. * \memberof dpp::cluster */ -auto inline co_stage_instance_delete(const snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->stage_instance_delete(channel_id, cc); }); -} +awaitable co_stage_instance_delete(const snowflake channel_id); /** * @brief Create a sticker in a guild @@ -1922,9 +1664,7 @@ auto inline co_stage_instance_delete(const snowflake channel_id) { * @return sticker returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_sticker_create(sticker &s) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_sticker_create(s, cc); }); -} +awaitable co_guild_sticker_create(sticker &s); /** * @brief Delete a sticker from a guild @@ -1936,9 +1676,7 @@ auto inline co_guild_sticker_create(sticker &s) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_sticker_delete(snowflake sticker_id, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_sticker_delete(sticker_id, guild_id, cc); }); -} +awaitable co_guild_sticker_delete(snowflake sticker_id, snowflake guild_id); /** * @brief Get a guild sticker @@ -1949,9 +1687,7 @@ auto inline co_guild_sticker_delete(snowflake sticker_id, snowflake guild_id) { * @return sticker returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_sticker_get(snowflake id, snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_sticker_get(id, guild_id, cc); }); -} +awaitable co_guild_sticker_get(snowflake id, snowflake guild_id); /** * @brief Modify a sticker in a guild @@ -1962,9 +1698,7 @@ auto inline co_guild_sticker_get(snowflake id, snowflake guild_id) { * @return sticker returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_sticker_modify(sticker &s) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_sticker_modify(s, cc); }); -} +awaitable co_guild_sticker_modify(sticker &s); /** * @brief Get all guild stickers @@ -1974,9 +1708,7 @@ auto inline co_guild_sticker_modify(sticker &s) { * @return sticker_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_stickers_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_stickers_get(guild_id, cc); }); -} +awaitable co_guild_stickers_get(snowflake guild_id); /** * @brief Get a nitro sticker @@ -1986,9 +1718,7 @@ auto inline co_guild_stickers_get(snowflake guild_id) { * @return sticker returned object on completion * \memberof dpp::cluster */ -auto inline co_nitro_sticker_get(snowflake id) { - return dpp::awaitable(this, [&] (auto cc) { this->nitro_sticker_get(id, cc); }); -} +awaitable co_nitro_sticker_get(snowflake id); /** * @brief Get sticker packs @@ -1997,9 +1727,7 @@ auto inline co_nitro_sticker_get(snowflake id) { * @return sticker_pack_map returned object on completion * \memberof dpp::cluster */ -auto inline co_sticker_packs_get() { - return dpp::awaitable(this, [&] (auto cc) { this->sticker_packs_get(cc); }); -} +awaitable co_sticker_packs_get(); /** * @brief Create a new guild based on a template. @@ -2011,9 +1739,7 @@ auto inline co_sticker_packs_get() { * @return guild returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_create_from_template(const std::string &code, const std::string &name) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_create_from_template(code, name, cc); }); -} +awaitable co_guild_create_from_template(const std::string &code, const std::string &name); /** * @brief Creates a template for the guild @@ -2026,9 +1752,7 @@ auto inline co_guild_create_from_template(const std::string &code, const std::st * @return dtemplate returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_template_create(snowflake guild_id, const std::string &name, const std::string &description) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_template_create(guild_id, name, description, cc); }); -} +awaitable co_guild_template_create(snowflake guild_id, const std::string &name, const std::string &description); /** * @brief Deletes the template @@ -2040,9 +1764,7 @@ auto inline co_guild_template_create(snowflake guild_id, const std::string &name * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_template_delete(snowflake guild_id, const std::string &code) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_template_delete(guild_id, code, cc); }); -} +awaitable co_guild_template_delete(snowflake guild_id, const std::string &code); /** * @brief Modifies the template's metadata. @@ -2056,9 +1778,7 @@ auto inline co_guild_template_delete(snowflake guild_id, const std::string &code * @return dtemplate returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_template_modify(snowflake guild_id, const std::string &code, const std::string &name, const std::string &description) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_template_modify(guild_id, code, name, description, cc); }); -} +awaitable co_guild_template_modify(snowflake guild_id, const std::string &code, const std::string &name, const std::string &description); /** * @brief Get guild templates @@ -2069,9 +1789,7 @@ auto inline co_guild_template_modify(snowflake guild_id, const std::string &code * @return dtemplate_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_templates_get(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_templates_get(guild_id, cc); }); -} +awaitable co_guild_templates_get(snowflake guild_id); /** * @brief Syncs the template to the guild's current state. @@ -2083,9 +1801,7 @@ auto inline co_guild_templates_get(snowflake guild_id) { * @return dtemplate returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_template_sync(snowflake guild_id, const std::string &code) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_template_sync(guild_id, code, cc); }); -} +awaitable co_guild_template_sync(snowflake guild_id, const std::string &code); /** * @brief Get a template @@ -2095,9 +1811,7 @@ auto inline co_guild_template_sync(snowflake guild_id, const std::string &code) * @return dtemplate returned object on completion * \memberof dpp::cluster */ -auto inline co_template_get(const std::string &code) { - return dpp::awaitable(this, [&] (auto cc) { this->template_get(code, cc); }); -} +awaitable co_template_get(const std::string &code); /** * @brief Join a thread @@ -2107,9 +1821,7 @@ auto inline co_template_get(const std::string &code) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_current_user_join_thread(snowflake thread_id) { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_join_thread(thread_id, cc); }); -} +awaitable co_current_user_join_thread(snowflake thread_id); /** * @brief Leave a thread @@ -2119,9 +1831,7 @@ auto inline co_current_user_join_thread(snowflake thread_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_current_user_leave_thread(snowflake thread_id) { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_leave_thread(thread_id, cc); }); -} +awaitable co_current_user_leave_thread(snowflake thread_id); /** * @brief Get all active threads in the guild, including public and private threads. Threads are ordered by their id, in descending order. @@ -2131,9 +1841,7 @@ auto inline co_current_user_leave_thread(snowflake thread_id) { * @return active_threads returned object on completion * \memberof dpp::cluster */ -auto inline co_threads_get_active(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->threads_get_active(guild_id, cc); }); -} +awaitable co_threads_get_active(snowflake guild_id); /** * @brief Get private archived threads in a channel which current user has joined (Sorted by ID in descending order) @@ -2145,9 +1853,7 @@ auto inline co_threads_get_active(snowflake guild_id) { * @return thread_map returned object on completion * \memberof dpp::cluster */ -auto inline co_threads_get_joined_private_archived(snowflake channel_id, snowflake before_id, uint16_t limit) { - return dpp::awaitable(this, [&] (auto cc) { this->threads_get_joined_private_archived(channel_id, before_id, limit, cc); }); -} +awaitable co_threads_get_joined_private_archived(snowflake channel_id, snowflake before_id, uint16_t limit); /** * @brief Get private archived threads in a channel (Sorted by archive_timestamp in descending order) @@ -2159,9 +1865,7 @@ auto inline co_threads_get_joined_private_archived(snowflake channel_id, snowfla * @return thread_map returned object on completion * \memberof dpp::cluster */ -auto inline co_threads_get_private_archived(snowflake channel_id, time_t before_timestamp, uint16_t limit) { - return dpp::awaitable(this, [&] (auto cc) { this->threads_get_private_archived(channel_id, before_timestamp, limit, cc); }); -} +awaitable co_threads_get_private_archived(snowflake channel_id, time_t before_timestamp, uint16_t limit); /** * @brief Get public archived threads in a channel (Sorted by archive_timestamp in descending order) @@ -2173,9 +1877,7 @@ auto inline co_threads_get_private_archived(snowflake channel_id, time_t before_ * @return thread_map returned object on completion * \memberof dpp::cluster */ -auto inline co_threads_get_public_archived(snowflake channel_id, time_t before_timestamp, uint16_t limit) { - return dpp::awaitable(this, [&] (auto cc) { this->threads_get_public_archived(channel_id, before_timestamp, limit, cc); }); -} +awaitable co_threads_get_public_archived(snowflake channel_id, time_t before_timestamp, uint16_t limit); /** * @brief Get a thread member @@ -2186,9 +1888,7 @@ auto inline co_threads_get_public_archived(snowflake channel_id, time_t before_t * @return thread_member returned object on completion * \memberof dpp::cluster */ -auto inline co_thread_member_get(const snowflake thread_id, const snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->thread_member_get(thread_id, user_id, cc); }); -} +awaitable co_thread_member_get(const snowflake thread_id, const snowflake user_id); /** * @brief Get members of a thread @@ -2198,9 +1898,7 @@ auto inline co_thread_member_get(const snowflake thread_id, const snowflake user * @return thread_member_map returned object on completion * \memberof dpp::cluster */ -auto inline co_thread_members_get(snowflake thread_id) { - return dpp::awaitable(this, [&] (auto cc) { this->thread_members_get(thread_id, cc); }); -} +awaitable co_thread_members_get(snowflake thread_id); /** * @brief Create a thread in forum channel @@ -2217,9 +1915,7 @@ auto inline co_thread_members_get(snowflake thread_id) { * @return thread returned object on completion * \memberof dpp::cluster */ -auto inline co_thread_create_in_forum(const std::string& thread_name, snowflake channel_id, const message& msg, auto_archive_duration_t auto_archive_duration, uint16_t rate_limit_per_user, std::vector applied_tags) { - return dpp::awaitable(this, [&] (auto cc) { this->thread_create_in_forum(thread_name, channel_id, msg, auto_archive_duration, rate_limit_per_user, applied_tags, cc); }); -} +awaitable co_thread_create_in_forum(const std::string& thread_name, snowflake channel_id, const message& msg, auto_archive_duration_t auto_archive_duration, uint16_t rate_limit_per_user, std::vector applied_tags = {}); /** * @brief Create a thread @@ -2236,9 +1932,7 @@ auto inline co_thread_create_in_forum(const std::string& thread_name, snowflake * @return thread returned object on completion * \memberof dpp::cluster */ -auto inline co_thread_create(const std::string& thread_name, snowflake channel_id, uint16_t auto_archive_duration, channel_type thread_type, bool invitable, uint16_t rate_limit_per_user) { - return dpp::awaitable(this, [&] (auto cc) { this->thread_create(thread_name, channel_id, auto_archive_duration, thread_type, invitable, rate_limit_per_user, cc); }); -} +awaitable co_thread_create(const std::string& thread_name, snowflake channel_id, uint16_t auto_archive_duration, channel_type thread_type, bool invitable, uint16_t rate_limit_per_user); /** * @brief Edit a thread @@ -2250,9 +1944,7 @@ auto inline co_thread_create(const std::string& thread_name, snowflake channel_i * @return thread returned object on completion * \memberof dpp::cluster */ -auto inline co_thread_edit(const thread &t) { - return dpp::awaitable(this, [&] (auto cc) { this->thread_edit(t, cc); }); -} +awaitable co_thread_edit(const thread &t); /** * @brief Create a thread with a message (Discord: ID of a thread is same as message ID) @@ -2267,9 +1959,7 @@ auto inline co_thread_edit(const thread &t) { * @return thread returned object on completion * \memberof dpp::cluster */ -auto inline co_thread_create_with_message(const std::string& thread_name, snowflake channel_id, snowflake message_id, uint16_t auto_archive_duration, uint16_t rate_limit_per_user) { - return dpp::awaitable(this, [&] (auto cc) { this->thread_create_with_message(thread_name, channel_id, message_id, auto_archive_duration, rate_limit_per_user, cc); }); -} +awaitable co_thread_create_with_message(const std::string& thread_name, snowflake channel_id, snowflake message_id, uint16_t auto_archive_duration, uint16_t rate_limit_per_user); /** * @brief Add a member to a thread @@ -2280,9 +1970,7 @@ auto inline co_thread_create_with_message(const std::string& thread_name, snowfl * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_thread_member_add(snowflake thread_id, snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->thread_member_add(thread_id, user_id, cc); }); -} +awaitable co_thread_member_add(snowflake thread_id, snowflake user_id); /** * @brief Remove a member from a thread @@ -2293,9 +1981,7 @@ auto inline co_thread_member_add(snowflake thread_id, snowflake user_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_thread_member_remove(snowflake thread_id, snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->thread_member_remove(thread_id, user_id, cc); }); -} +awaitable co_thread_member_remove(snowflake thread_id, snowflake user_id); /** * @brief Edit current (bot) user @@ -2311,9 +1997,7 @@ auto inline co_thread_member_remove(snowflake thread_id, snowflake user_id) { * @throw dpp::length_exception Image data is larger than the maximum size of 256 kilobytes * \memberof dpp::cluster */ -auto inline co_current_user_edit(const std::string &nickname, const std::string& image_blob, const image_type type) { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_edit(nickname, image_blob, type, cc); }); -} +awaitable co_current_user_edit(const std::string &nickname, const std::string& image_blob = "", const image_type type = i_png); /** * @brief Get current (bot) application @@ -2323,9 +2007,7 @@ auto inline co_current_user_edit(const std::string &nickname, const std::string& * @return application returned object on completion * \memberof dpp::cluster */ -auto inline co_current_application_get() { - return dpp::awaitable(this, [&] (auto cc) { this->current_application_get(cc); }); -} +awaitable co_current_application_get(); /** * @brief Get current (bot) user @@ -2337,9 +2019,7 @@ auto inline co_current_application_get() { * If you do not have these scopes, these fields are empty. You can safely convert a user_identified to user with `dynamic_cast`. * \memberof dpp::cluster */ -auto inline co_current_user_get() { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_get(cc); }); -} +awaitable co_current_user_get(); /** * @brief Set the bot's voice state on a stage channel @@ -2364,9 +2044,7 @@ auto inline co_current_user_get() { * @throw std::logic_exception You attempted to set a request_to_speak_timestamp in the past which is not the value of 0. * \memberof dpp::cluster */ -auto inline co_current_user_set_voice_state(snowflake guild_id, snowflake channel_id, bool suppress, time_t request_to_speak_timestamp) { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_set_voice_state(guild_id, channel_id, suppress, request_to_speak_timestamp, cc); }); -} +awaitable co_current_user_set_voice_state(snowflake guild_id, snowflake channel_id, bool suppress = false, time_t request_to_speak_timestamp = 0); /** * @brief Set a user's voice state on a stage channel @@ -2390,9 +2068,7 @@ auto inline co_current_user_set_voice_state(snowflake guild_id, snowflake channe * @param suppress True if the user's audio should be suppressed, false if it should not * \memberof dpp::cluster */ -auto inline co_user_set_voice_state(snowflake user_id, snowflake guild_id, snowflake channel_id, bool suppress) { - return dpp::awaitable(this, [&] (auto cc) { this->user_set_voice_state(user_id, guild_id, channel_id, suppress, cc); }); -} +awaitable co_user_set_voice_state(snowflake user_id, snowflake guild_id, snowflake channel_id, bool suppress = false); /** * @brief Get current user's connections (linked accounts, e.g. steam, xbox). @@ -2403,9 +2079,7 @@ auto inline co_user_set_voice_state(snowflake user_id, snowflake guild_id, snowf * @return connection_map returned object on completion * \memberof dpp::cluster */ -auto inline co_current_user_connections_get() { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_connections_get(cc); }); -} +awaitable co_current_user_connections_get(); /** * @brief Get current (bot) user guilds @@ -2414,9 +2088,7 @@ auto inline co_current_user_connections_get() { * @return guild_map returned object on completion * \memberof dpp::cluster */ -auto inline co_current_user_get_guilds() { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_get_guilds(cc); }); -} +awaitable co_current_user_get_guilds(); /** * @brief Leave a guild @@ -2426,9 +2098,7 @@ auto inline co_current_user_get_guilds() { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_current_user_leave_guild(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->current_user_leave_guild(guild_id, cc); }); -} +awaitable co_current_user_leave_guild(snowflake guild_id); /** * @brief Get a user by id, without using the cache @@ -2443,9 +2113,7 @@ auto inline co_current_user_leave_guild(snowflake guild_id) { * Call `dpp::find_user` instead that looks up the user in the cache rather than a REST call. * \memberof dpp::cluster */ -auto inline co_user_get(snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->user_get(user_id, cc); }); -} +awaitable co_user_get(snowflake user_id); /** * @brief Get a user by id, checking in the cache first @@ -2460,9 +2128,7 @@ auto inline co_user_get(snowflake user_id) { * where you want to for example resolve a user who may no longer be in the bot's guilds, for something like a ban log message. * \memberof dpp::cluster */ -auto inline co_user_get_cached(snowflake user_id) { - return dpp::awaitable(this, [&] (auto cc) { this->user_get_cached(user_id, cc); }); -} +awaitable co_user_get_cached(snowflake user_id); /** * @brief Get all voice regions @@ -2471,9 +2137,7 @@ auto inline co_user_get_cached(snowflake user_id) { * @return voiceregion_map returned object on completion * \memberof dpp::cluster */ -auto inline co_get_voice_regions() { - return dpp::awaitable(this, [&] (auto cc) { this->get_voice_regions(cc); }); -} +awaitable co_get_voice_regions(); /** * @brief Get guild voice regions. @@ -2488,9 +2152,7 @@ auto inline co_get_voice_regions() { * @return voiceregion_map returned object on completion * \memberof dpp::cluster */ -auto inline co_guild_get_voice_regions(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->guild_get_voice_regions(guild_id, cc); }); -} +awaitable co_guild_get_voice_regions(snowflake guild_id); /** * @brief Create a webhook @@ -2501,9 +2163,7 @@ auto inline co_guild_get_voice_regions(snowflake guild_id) { * @return webhook returned object on completion * \memberof dpp::cluster */ -auto inline co_create_webhook(const class webhook &w) { - return dpp::awaitable(this, [&] (auto cc) { this->create_webhook(w, cc); }); -} +awaitable co_create_webhook(const class webhook &w); /** * @brief Delete a webhook @@ -2514,9 +2174,7 @@ auto inline co_create_webhook(const class webhook &w) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_delete_webhook(snowflake webhook_id) { - return dpp::awaitable(this, [&] (auto cc) { this->delete_webhook(webhook_id, cc); }); -} +awaitable co_delete_webhook(snowflake webhook_id); /** * @brief Delete webhook message @@ -2529,9 +2187,7 @@ auto inline co_delete_webhook(snowflake webhook_id) { * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_delete_webhook_message(const class webhook &wh, snowflake message_id, snowflake thread_id) { - return dpp::awaitable(this, [&] (auto cc) { this->delete_webhook_message(wh, message_id, thread_id, cc); }); -} +awaitable co_delete_webhook_message(const class webhook &wh, snowflake message_id, snowflake thread_id = 0); /** * @brief Delete webhook with token @@ -2542,9 +2198,7 @@ auto inline co_delete_webhook_message(const class webhook &wh, snowflake message * @return confirmation returned object on completion * \memberof dpp::cluster */ -auto inline co_delete_webhook_with_token(snowflake webhook_id, const std::string &token) { - return dpp::awaitable(this, [&] (auto cc) { this->delete_webhook_with_token(webhook_id, token, cc); }); -} +awaitable co_delete_webhook_with_token(snowflake webhook_id, const std::string &token); /** * @brief Edit webhook @@ -2555,9 +2209,7 @@ auto inline co_delete_webhook_with_token(snowflake webhook_id, const std::string * @return webhook returned object on completion * \memberof dpp::cluster */ -auto inline co_edit_webhook(const class webhook& wh) { - return dpp::awaitable(this, [&] (auto cc) { this->edit_webhook(wh, cc); }); -} +awaitable co_edit_webhook(const class webhook& wh); /** * @brief Edit webhook message @@ -2576,9 +2228,7 @@ auto inline co_edit_webhook(const class webhook& wh) { * @return message returned object on completion * \memberof dpp::cluster */ -auto inline co_edit_webhook_message(const class webhook &wh, const struct message& m, snowflake thread_id) { - return dpp::awaitable(this, [&] (auto cc) { this->edit_webhook_message(wh, m, thread_id, cc); }); -} +awaitable co_edit_webhook_message(const class webhook &wh, const struct message &m, snowflake thread_id = 0); /** * @brief Edit webhook with token (token is encapsulated in the webhook object) @@ -2588,9 +2238,7 @@ auto inline co_edit_webhook_message(const class webhook &wh, const struct messag * @return webhook returned object on completion * \memberof dpp::cluster */ -auto inline co_edit_webhook_with_token(const class webhook& wh) { - return dpp::awaitable(this, [&] (auto cc) { this->edit_webhook_with_token(wh, cc); }); -} +awaitable co_edit_webhook_with_token(const class webhook& wh); /** * @brief Execute webhook @@ -2606,9 +2254,7 @@ auto inline co_edit_webhook_with_token(const class webhook& wh) { * @note If the webhook channel is a forum channel, you must provide either `thread_id` or `thread_name`. If `thread_id` is provided, the message will send in that thread. If `thread_name` is provided, a thread with that name will be created in the forum channel. * \memberof dpp::cluster */ -auto inline co_execute_webhook(const class webhook &wh, const struct message& m, bool wait, snowflake thread_id, const std::string& thread_name) { - return dpp::awaitable(this, [&] (auto cc) { this->execute_webhook(wh, m, wait, thread_id, thread_name, cc); }); -} +awaitable co_execute_webhook(const class webhook &wh, const struct message &m, bool wait = false, snowflake thread_id = 0, const std::string& thread_name = ""); /** * @brief Get channel webhooks @@ -2618,9 +2264,7 @@ auto inline co_execute_webhook(const class webhook &wh, const struct message& m, * @return webhook_map returned object on completion * \memberof dpp::cluster */ -auto inline co_get_channel_webhooks(snowflake channel_id) { - return dpp::awaitable(this, [&] (auto cc) { this->get_channel_webhooks(channel_id, cc); }); -} +awaitable co_get_channel_webhooks(snowflake channel_id); /** * @brief Get guild webhooks @@ -2630,9 +2274,7 @@ auto inline co_get_channel_webhooks(snowflake channel_id) { * @return webhook_map returned object on completion * \memberof dpp::cluster */ -auto inline co_get_guild_webhooks(snowflake guild_id) { - return dpp::awaitable(this, [&] (auto cc) { this->get_guild_webhooks(guild_id, cc); }); -} +awaitable co_get_guild_webhooks(snowflake guild_id); /** * @brief Get webhook @@ -2642,9 +2284,7 @@ auto inline co_get_guild_webhooks(snowflake guild_id) { * @return webhook returned object on completion * \memberof dpp::cluster */ -auto inline co_get_webhook(snowflake webhook_id) { - return dpp::awaitable(this, [&] (auto cc) { this->get_webhook(webhook_id, cc); }); -} +awaitable co_get_webhook(snowflake webhook_id); /** * @brief Get webhook message @@ -2657,9 +2297,7 @@ auto inline co_get_webhook(snowflake webhook_id) { * @return message returned object on completion * \memberof dpp::cluster */ -auto inline co_get_webhook_message(const class webhook &wh, snowflake message_id, snowflake thread_id) { - return dpp::awaitable(this, [&] (auto cc) { this->get_webhook_message(wh, message_id, thread_id, cc); }); -} +awaitable co_get_webhook_message(const class webhook &wh, snowflake message_id, snowflake thread_id = 0); /** * @brief Get webhook using token @@ -2670,13 +2308,9 @@ auto inline co_get_webhook_message(const class webhook &wh, snowflake message_id * @return webhook returned object on completion * \memberof dpp::cluster */ -auto inline co_get_webhook_with_token(snowflake webhook_id, const std::string &token) { - return dpp::awaitable(this, [&] (auto cc) { this->get_webhook_with_token(webhook_id, token, cc); }); -} +awaitable co_get_webhook_with_token(snowflake webhook_id, const std::string &token); /* End of auto-generated definitions */ -auto inline co_request(const std::string &url, http_method method, const std::string &postdata = "", const std::string &mimetype = "text/plain", const std::multimap &headers = {}) { - return dpp::awaitable(this, [&] (auto cc) { this->request(url, method, cc, mimetype, headers); }); -} +awaitable co_request(const std::string &url, http_method method, const std::string &postdata = "", const std::string &mimetype = "text/plain", const std::multimap &headers = {}); diff --git a/include/dpp/coro.h b/include/dpp/coro.h index 900a67e43b..ceefa78b6d 100644 --- a/include/dpp/coro.h +++ b/include/dpp/coro.h @@ -1,158 +1,467 @@ #ifdef DPP_CORO #pragma once -#include + +#if !(defined( _MSC_VER ) || defined( _CONSOLE ) || defined( __GNUC__ )) // if libc++ +# define EXPERIMENTAL_COROUTINE +#endif + +#ifdef EXPERIMENTAL_COROUTINE +# include +#else +# include +#endif + +#include +#include +#include #include namespace dpp { - - /** - * @brief Shorthand for the coroutine handle's type - */ - using handle_type = std::coroutine_handle; +#ifdef EXPERIMENTAL_COROUTINE + namespace std_coroutine = std::experimental; +#else + namespace std_coroutine = std; +#endif +} +namespace dpp { class cluster; - /** - * @brief Return type for coroutines - */ - struct task { + namespace detail { + /** + * @brief A co_task's promise type. Meant to be opaque to the user, and not used directly + */ + template + struct co_task_promise; + /** - * @brief Required nested promise_type for coroutines + * @brief The object returned from a promise */ - using promise_type = dpp::promise; - }; + template + struct co_task_chain_final_awaiter; + + /** + * @brief A co_task's coroutine handle type + * + * @see co_task_promise + */ + template + using co_task_handle = std_coroutine::coroutine_handle>; + } /** - * @brief Implementation of promise_type for dpp's coroutines - */ - struct promise { + * @brief Basic implementation of a coroutine. It can be co_awaited to make nested coroutines, waiting on a set of coroutines. + * Meant to be used in conjunction with coroutine events (@see event_router::co_attach), or on its own, in which case the user is responsible for keeping the lifetime of the co_task object until it ends + */ + template + class co_task { /** - * @brief A pointer to the cluster making the requests in the coroutine + * @brief The coroutine handle of this task. */ - cluster* bot = nullptr; + detail::co_task_handle handle; + + protected: + friend struct detail::co_task_promise; /** - * @brief The result of the last co_await-ed function + * @brief Construct from a coroutine handle. Internal use only */ - confirmation_callback_t callback; + explicit co_task(detail::co_task_handle handle_) : handle(handle_) {} + public: /** - * @brief Construct a new promise object + * @brief Default constructor with no coroutine */ - promise() = default; + co_task() = default; /** - * @brief Construct a new promise object - * - * @param ev Base type of all events, only used to get the dpp::cluster pointer + * @brief Copy constructor is disabled */ - promise(const dpp::event_dispatch_t& ev) : bot(ev.from->creator) { } + co_task(const co_task &) = delete; /** - * @brief Get the return object - * - * @return task dpp::task type + * @brief Move constructor, grabs another task's coroutine handle + * + * @param other Task to move the handle from */ - task get_return_object() { - return {}; - } + co_task(co_task &&other) noexcept : handle(std::exchange(other.handle, nullptr)) {} + /** - * @brief Function called when the coroutine is first suspended, never suspends - * - * @return std::suspend_never Never suspend this coroutine at the first suspend point + * @brief Task's destructor. Destroys the handle if coroutine is done, otherwise tell it to destroy itself (detaches it from this thread) */ - std::suspend_never initial_suspend() noexcept { - return {}; + ~co_task() + { + if (handle) { + if (handle.done()) { + // if the coroutine is done, we can destroy it now + handle.destroy(); + } + else { + // if the coroutine is still running, we tell it to destroy itself at the end + handle.promise().self_destruct = true; + } + } } /** - * @brief Function called when the coroutine reaches its last suspension point - * - * @return std::suspend_never Never suspend this coroutine at the final suspend point + * @brief Copy assignment is disabled */ - std::suspend_never final_suspend() noexcept { - return {}; - } + co_task &operator=(const co_task &) = delete; /** - * @brief Function called when the coroutine returns nothing + * @brief Move assignment, grabs another task's coroutine handle + * + * @param other Task to move the handle from */ - void return_void() noexcept {} + co_task &operator=(co_task &&other) noexcept { + handle = std::exchange(other.handle, nullptr); + return (*this); + } /** - * @brief Function called when coroutine throws a un-catch-ed exception. Does nothing - */ - void unhandled_exception() { - /* try { std::rethrow_exception(std::current_exception()); } */ - /* catch (const std::exception& e) { std::cout << e.what() << '\n'; } */ + * @brief First function called by the standard library when the task is co_await-ed. + * + * @return bool Whether to suspend the caller or not + */ + bool await_ready() { + return handle.done(); + } + + /** + * @brief Second step when the task is co_await-ed. We store the suspended coroutine in the promise to resume when we're done + * + * @param caller The calling/suspended coroutine + * @return bool Whether to suspend the caller or not + */ + bool await_suspend(std_coroutine::coroutine_handle<> caller) { + auto &my_promise = handle.promise(); + + // TODO: sync tasks + if (my_promise.is_sync) + return false; + my_promise.parent = caller; + my_promise.is_sync = false; + return true; + } + + /* + * @brief Function called when the coroutine is resumed. + * + * @return ReturnType The result of the coroutine. It is the value the whole co-await expression evaluates to + */ + ReturnType await_resume(); + + /* + * @brief Function to check if the coroutine has finished its execution entirely + * + * @return bool Whether the coroutine is done. + * @see https://en.cppreference.com/w/cpp/coroutine/coroutine_handle/done + */ + bool done() const noexcept { + return handle.done(); } }; + namespace detail { + /** + * @brief Awaitable returned from co_task_promise's final_suspend. Resumes the parent and cleans up its handle if needed + */ + template + struct co_task_chain_final_awaiter { + /** + * @brief Always suspend at the end of the task. This allows us to clean up and resume the parent + */ + bool await_ready() noexcept { + return (false); + } + + /* + * @brief The suspension logic of the coroutine when it finishes. Always suspend the caller, meaning cleaning up the handle is on us + * + * @param handle The handle of this coroutine + */ + void await_suspend(detail::co_task_handle handle) noexcept; + + /* + * @brief Function called when this object is co_awaited by the standard library at the end of final_suspend. Do nothing, return nothing + */ + void await_resume() noexcept {} + }; + /** + * @brief Base implementation of promise_type, without the logic that would depend on the return type. Meant to be inherited from + */ + struct co_task_promise_base { + /** + * @brief Parent coroutine to return to for nested coroutines. + */ + std_coroutine::coroutine_handle<> parent = nullptr; + + /** + * @brief Exception ptr if any was thrown during the coroutine + */ + std::exception_ptr exception = nullptr; + + /** + * @brief Whether the coroutine has async calls or not + */ + bool is_sync = true; + + /* + * @brief Whether the promise should clean the handle up when it finishes + */ + bool self_destruct = false; + + /** + * @brief Function called by the standard library when the coroutine is created. + * + * @return std::suspend_never Don't suspend, we want to start immediately on the caller. + */ + std::suspend_never initial_suspend() noexcept { + return {}; + } + + /* + * @brief Function called by the standard library when an exception is thrown and not caught in the coroutine. Stores the exception pointer to rethrow later + */ + void unhandled_exception() { + exception = std::current_exception(); + } + }; + + /** + * @brief Implementation of promise_base for non-void return type + */ + template + struct co_task_promise : co_task_promise_base { + /** + * @brief Stored return value of the coroutine. + * + * @details The main reason we use optional here and not ReturnType is to avoid default construction of the value so we only require ReturnType to have a move constructor, instead of a default constructor and move assignment operator + */ + std::optional value = std::nullopt; + + /** + * @brief Function called when the coroutine returns a value. Store it internally to hand to the caller later + */ + void return_value(ReturnType expr) { + value = std::forward(expr); + } + + /** + * @brief Type of the coroutine + * + * @return co_task The coroutine object + */ + co_task get_return_object() { + return co_task{co_task_handle::from_promise(*this)}; + } + + /** + * @brief Function called when the coroutine reaches its last suspension point + * + * @return co_task_chain_final_awaiter Special object containing the cleaning up logic + */ + co_task_chain_final_awaiter final_suspend() noexcept { + return {}; + } + }; + + template <> + struct co_task_promise : co_task_promise_base { + /** + * @brief Function called when the coroutine returns a value. We have void so do nothing + */ + void return_void() { + } + + /** + * @brief Type of the coroutine + * + * @return co_task The coroutine object + */ + co_task get_return_object() { + return co_task{co_task_handle::from_promise(*this)}; + } + + /** + * @brief Function called when the coroutine reaches its last suspension point + * + * @return co_task_chain_final_awaiter Special object containing the cleaning up logic + */ + co_task_chain_final_awaiter final_suspend() noexcept { + return {}; + } + }; + + template + void detail::co_task_chain_final_awaiter::await_suspend(detail::co_task_handle handle) noexcept { + co_task_promise &promise = handle.promise(); + std::coroutine_handle<> parent = promise.parent; + + if (promise.self_destruct) + handle.destroy(); + if (parent) + parent.resume(); + } + } + + template + ReturnType co_task::await_resume() { + if (handle.promise().exception) // If we have an exception, rethrow + std::rethrow_exception(handle.promise().exception); + if constexpr (!std::is_same_v) // If we have a return type, return it and clean up our stored value + return std::forward(*std::exchange(handle.promise().value, std::nullopt)); + } + /** - * @brief A co_await-able struct which returns the result of stored api call when co_await-ed. Meant to be opaque to the user - * - * @tparam T The type of the function (lambda if auto-generated by the php script) handling the making of api call + * @brief An object that can be co_await-ed, wrapping an API call. + * This class is the return of the cluster::co_* methods, but it can also be created manually to wrap any async call. + * + * @warn The behavior is undefined if the object is co_awaited more than once. + * @tparam ReturnType The return type of the API call. Defaults to confirmation_callback_t */ - template - struct awaitable { + template + class awaitable { /** - * @brief Pointer to the nested promise object of the coroutine, used for storing and retrieving the result of an api call + * @brief State of the awaitable and its callback. */ - promise* p; - + struct callback_data { + /** + * @brief The stored result of the API call + */ + std::optional result; + + /** + * @brief Mutex to ensure the API result isn't set at the same time the coroutine is awaited and its value is checked + */ + std::mutex mutex; + + /** + * @brief Handle to the coroutine co_await-ing on this API call + */ + std::coroutine_handle<> coro_handle = nullptr; + }; + /** - * @brief Pointer to the cluster making the api request + * @brief State of the awaitable and its callback. We wrap it in a unique_ptr because std::mutex is not moveable, and we want to make awaitable moveable */ - cluster* bot; + std::unique_ptr data = nullptr; + public: /** - * @brief The function handling the making of request, using the cluster pointer + * @brief Construct an awaitable wrapping an API call of an object method + * The API call is made immediately and can be awaited later + * + * @param obj The object to call the method on + * @param fun The method of the object to call. Its last parameter must be a callback taking a parameter of type R + * @param args Parameters to pass to the method, excluding the callback */ - T api_req; + template + requires (std::invocable>) + awaitable(Obj &&obj, Fun &&fun, Args&&... args) : data{std::make_unique()} { + std::invoke(fun, obj, std::forward(args)..., ([cb_data = data.get()](const ReturnType& cback) { + std::unique_lock lock{cb_data->mutex}; + + cb_data->result = cback; + if (cb_data->coro_handle) { + auto handle = cb_data->coro_handle; + cb_data->coro_handle = nullptr; + lock.unlock(); + handle.resume(); + } + })); + } + + /** + * @brief Construct an awaitable wrapping an invokeable object + * The call is made immediately and can be awaited later + * + * @param fun The object to call using std::invoke. Its last parameter must be a callable taking a parameter of type R + * @param args Parameters to pass to the object, excluding the callback + */ + template + requires (std::invocable>) + awaitable(Fun &&fun, Args&&... args) : data{std::make_unique()} { + std::invoke(fun, std::forward(args)..., ([cb_data = data.get()](const ReturnType& cback) { + std::unique_lock lock{cb_data->mutex}; + + cb_data->result = cback; + if (cb_data->coro_handle) { + auto handle = cb_data->coro_handle; + cb_data->coro_handle = nullptr; + lock.unlock(); + handle.resume(); + } + })); + } + + /** + * @brief Copy constructor is disabled + */ + awaitable(const awaitable &) = delete; /** - * @brief Construct a new awaitable object - * - * @param cl pointer to the cluster making the api request - * @param api_call a function to invoke with the cluster pointer, handles the making of request + * @brief Move constructor, defaulted to grab the callback data from another awaitable */ - awaitable(cluster* cl, T api_call) : bot{cl}, api_req{api_call} {} + awaitable(awaitable &&other) = default; /** - * @brief First function called when this object is co_await-ed, its return type tells if the coroutine should be immediately suspended - * - * @return bool false, signifying immediate suspension + * @brief Copy assignment is disabled + */ + awaitable &operator=(const awaitable &) = delete; + + /** + * @brief Move assignment, defaulted to grab the callback data from another awaitable + */ + awaitable &operator=(awaitable &&) = default; + + /** + * @brief First function called by the standard library when the object is co-awaited. The return type signifies whether we need to suspend the caller or not. + * Do not call this manually + * + * @return bool Whether we already have the result of the API call or not */ bool await_ready() noexcept { - return false; + std::lock_guard lock{data->mutex}; + + return data->result.has_value(); } /** - * @brief Function called when the coroutine is suspended, makes the api request and queues the resumption of the suspended coroutine, storing the result in promise object - * - * @param handle the handle to the suspended coroutine + * @brief Second function called by the standard library when the object is co-awaited, if await_ready returned false. Here we do the same logic as await_ready for whether to suspend or not, if true we store the coroutine to resume after the API call is done. Do not call this manually + * + * @param handle The handle to the coroutine co_await-ing and being suspended */ - void await_suspend(handle_type handle) { - /* p = &handle.promise(); */ - /* if (!p->bot) p->bot = bot; */ - api_req([handle](const confirmation_callback_t& cback) { handle.promise().callback = cback; handle.resume(); }); + template + bool await_suspend(std::coroutine_handle> handle) + { + std::lock_guard lock{data->mutex}; + + if (data->result.has_value()) + return false; // immediately resume the coroutine as we already have the result of the api call + handle.promise().is_sync = false; + data->coro_handle = handle; + return true; // suspend the caller, the callback will resume it } /** - * @brief Function called when the coroutine is resumed by its handle, handles the retrieval and return of result from promise object - * - * @return confirmation_callback_t the result of the api call + * @brief Function called by the standard library when the awaitable is resumed. Its return value is what the whole co_await expression evaluates to + * + * @return confirmation_callback_t The result of the API call. */ confirmation_callback_t await_resume() { - return p->callback; + return std::move(*data->result); } }; +}; +/** + * @brief Specialization of std::coroutine_traits, helps the standard library figure out a promise type from a coroutine function. + */ +template +struct dpp::std_coroutine::coroutine_traits, Args...> { + using promise_type = dpp::detail::co_task_promise; }; -/* template<> */ -/* struct std::coroutine_traits { */ -/* using promise_type = dpp::promise; */ -/* }; */ #endif diff --git a/include/dpp/event_router.h b/include/dpp/event_router.h index 4f901fd394..a0656ca852 100644 --- a/include/dpp/event_router.h +++ b/include/dpp/event_router.h @@ -106,7 +106,7 @@ template class event_router_t { /** * @brief Container for event listeners (coroutines only) */ - std::map> coroutine_container; + std::map(T)>> coroutine_container; #else /** * @brief Dummy container to keep the struct size same @@ -223,7 +223,7 @@ template class event_router_t { } #ifdef DPP_CORO - event_handle co_attach(std::function func) { + event_handle co_attach(std::function(T)> func) { std::unique_lock l(lock); event_handle h = next_handle++; coroutine_container.emplace(h, func); diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 782afc717f..d120ee5c2e 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -170,9 +170,9 @@ endif() if(MSVC) if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /Od /DEBUG /Zi /sdl /DFD_SETSIZE=1024") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od /DEBUG /Zi /sdl /DFD_SETSIZE=1024") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /O2 /Oi /Oy /Gy /sdl /DFD_SETSIZE=1024") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Oi /Oy /Gy /sdl /DFD_SETSIZE=1024") endif() if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Zc:preprocessor") @@ -288,7 +288,7 @@ endif() if(DPP_CORO) message("-- ${Yellow}Enabled experimental coroutine support${ColourReset}") set(CMAKE_CXX_STANDARD 20) - target_compile_features(dpp PRIVATE cxx_std_20) + target_compile_features(dpp PUBLIC cxx_std_20) if(WIN32 AND NOT MINGW) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /await:strict") else() diff --git a/src/dpp/cluster_coro_calls.cpp b/src/dpp/cluster_coro_calls.cpp new file mode 100644 index 0000000000..220257fd74 --- /dev/null +++ b/src/dpp/cluster_coro_calls.cpp @@ -0,0 +1,774 @@ +/************************************************************************************ + * + * D++, A Lightweight C++ library for Discord + * + * Copyright 2022 Craig Edwards and D++ contributors + * (https://github.com/brainboxdotcc/DPP/graphs/contributors) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ************************************************************************************/ + + +/* Auto @generated by buildtools/make_coro_struct.php. + * + * DO NOT EDIT BY HAND! + * + * To re-generate this header file re-run the script! + */ +#ifdef DPP_CORO + +#include +#include +#include +#include + +namespace dpp { + +awaitable cluster::co_global_bulk_command_create(const std::vector &commands) { + return {this, static_cast &, command_completion_event_t)>(&cluster::global_bulk_command_create), commands}; +} + +awaitable cluster::co_global_command_create(const slashcommand &s) { + return {this, static_cast(&cluster::global_command_create), s}; +} + +awaitable cluster::co_global_command_get(snowflake id) { + return {this, static_cast(&cluster::global_command_get), id}; +} + +awaitable cluster::co_global_command_delete(snowflake id) { + return {this, static_cast(&cluster::global_command_delete), id}; +} + +awaitable cluster::co_global_command_edit(const slashcommand &s) { + return {this, static_cast(&cluster::global_command_edit), s}; +} + +awaitable cluster::co_global_commands_get() { + return {this, static_cast(&cluster::global_commands_get)}; +} + +awaitable cluster::co_guild_bulk_command_create(const std::vector &commands, snowflake guild_id) { + return {this, static_cast &, snowflake, command_completion_event_t)>(&cluster::guild_bulk_command_create), commands, guild_id}; +} + +awaitable cluster::co_guild_commands_get_permissions(snowflake guild_id) { + return {this, static_cast(&cluster::guild_commands_get_permissions), guild_id}; +} + +awaitable cluster::co_guild_bulk_command_edit_permissions(const std::vector &commands, snowflake guild_id) { + return {this, static_cast &, snowflake, command_completion_event_t)>(&cluster::guild_bulk_command_edit_permissions), commands, guild_id}; +} + +awaitable cluster::co_guild_command_create(const slashcommand &s, snowflake guild_id) { + return {this, static_cast(&cluster::guild_command_create), s, guild_id}; +} + +awaitable cluster::co_guild_command_delete(snowflake id, snowflake guild_id) { + return {this, static_cast(&cluster::guild_command_delete), id, guild_id}; +} + +awaitable cluster::co_guild_command_edit_permissions(const slashcommand &s, snowflake guild_id) { + return {this, static_cast(&cluster::guild_command_edit_permissions), s, guild_id}; +} + +awaitable cluster::co_guild_command_get(snowflake id, snowflake guild_id) { + return {this, static_cast(&cluster::guild_command_get), id, guild_id}; +} + +awaitable cluster::co_guild_command_get_permissions(snowflake id, snowflake guild_id) { + return {this, static_cast(&cluster::guild_command_get_permissions), id, guild_id}; +} + +awaitable cluster::co_guild_command_edit(const slashcommand &s, snowflake guild_id) { + return {this, static_cast(&cluster::guild_command_edit), s, guild_id}; +} + +awaitable cluster::co_guild_commands_get(snowflake guild_id) { + return {this, static_cast(&cluster::guild_commands_get), guild_id}; +} + +awaitable cluster::co_interaction_response_create(snowflake interaction_id, const std::string &token, const interaction_response &r) { + return {this, static_cast(&cluster::interaction_response_create), interaction_id, token, r}; +} + +awaitable cluster::co_interaction_response_edit(const std::string &token, const message &m) { + return {this, static_cast(&cluster::interaction_response_edit), token, m}; +} + +awaitable cluster::co_interaction_followup_create(const std::string &token, const message &m) { + return {this, static_cast(&cluster::interaction_followup_create), token, m}; +} + +awaitable cluster::co_interaction_followup_edit_original(const std::string &token, const message &m) { + return {this, static_cast(&cluster::interaction_followup_edit_original), token, m}; +} + +awaitable cluster::co_interaction_followup_delete(const std::string &token) { + return {this, static_cast(&cluster::interaction_followup_delete), token}; +} + +awaitable cluster::co_interaction_followup_edit(const std::string &token, const message &m) { + return {this, static_cast(&cluster::interaction_followup_edit), token, m}; +} + +awaitable cluster::co_interaction_followup_get(const std::string &token, snowflake message_id) { + return {this, static_cast(&cluster::interaction_followup_get), token, message_id}; +} + +awaitable cluster::co_automod_rules_get(snowflake guild_id) { + return {this, static_cast(&cluster::automod_rules_get), guild_id}; +} + +awaitable cluster::co_automod_rule_get(snowflake guild_id, snowflake rule_id) { + return {this, static_cast(&cluster::automod_rule_get), guild_id, rule_id}; +} + +awaitable cluster::co_automod_rule_create(snowflake guild_id, const automod_rule& r) { + return {this, static_cast(&cluster::automod_rule_create), guild_id, r}; +} + +awaitable cluster::co_automod_rule_edit(snowflake guild_id, const automod_rule& r) { + return {this, static_cast(&cluster::automod_rule_edit), guild_id, r}; +} + +awaitable cluster::co_automod_rule_delete(snowflake guild_id, snowflake rule_id) { + return {this, static_cast(&cluster::automod_rule_delete), guild_id, rule_id}; +} + +awaitable cluster::co_channel_create(const class channel &c) { + return {this, static_cast(&cluster::channel_create), c}; +} + +awaitable cluster::co_channel_delete_permission(const class channel &c, snowflake overwrite_id) { + return {this, static_cast(&cluster::channel_delete_permission), c, overwrite_id}; +} + +awaitable cluster::co_channel_delete(snowflake channel_id) { + return {this, static_cast(&cluster::channel_delete), channel_id}; +} + +awaitable cluster::co_channel_edit_permissions(const class channel &c, const snowflake overwrite_id, const uint64_t allow, const uint64_t deny, const bool member) { + return {this, static_cast(&cluster::channel_edit_permissions), c, overwrite_id, allow, deny, member}; +} + +awaitable cluster::co_channel_edit_permissions(const snowflake channel_id, const snowflake overwrite_id, const uint64_t allow, const uint64_t deny, const bool member) { + return {this, static_cast(&cluster::channel_edit_permissions), channel_id, overwrite_id, allow, deny, member}; +} + +awaitable cluster::co_channel_edit_positions(const std::vector &c) { + return {this, static_cast &, command_completion_event_t)>(&cluster::channel_edit_positions), c}; +} + +awaitable cluster::co_channel_edit(const class channel &c) { + return {this, static_cast(&cluster::channel_edit), c}; +} + +awaitable cluster::co_channel_follow_news(const class channel &c, snowflake target_channel_id) { + return {this, static_cast(&cluster::channel_follow_news), c, target_channel_id}; +} + +awaitable cluster::co_channel_get(snowflake c) { + return {this, static_cast(&cluster::channel_get), c}; +} + +awaitable cluster::co_channel_invite_create(const class channel &c, const class invite &i) { + return {this, static_cast(&cluster::channel_invite_create), c, i}; +} + +awaitable cluster::co_channel_invites_get(const class channel &c) { + return {this, static_cast(&cluster::channel_invites_get), c}; +} + +awaitable cluster::co_channel_typing(const class channel &c) { + return {this, static_cast(&cluster::channel_typing), c}; +} + +awaitable cluster::co_channel_typing(snowflake cid) { + return {this, static_cast(&cluster::channel_typing), cid}; +} + +awaitable cluster::co_channels_get(snowflake guild_id) { + return {this, static_cast(&cluster::channels_get), guild_id}; +} + +awaitable cluster::co_create_dm_channel(snowflake user_id) { + return {this, static_cast(&cluster::create_dm_channel), user_id}; +} + +awaitable cluster::co_current_user_get_dms() { + return {this, static_cast(&cluster::current_user_get_dms)}; +} + +awaitable cluster::co_direct_message_create(snowflake user_id, const message &m) { + return {this, static_cast(&cluster::direct_message_create), user_id, m}; +} + +awaitable cluster::co_gdm_add(snowflake channel_id, snowflake user_id, const std::string &access_token, const std::string &nick) { + return {this, static_cast(&cluster::gdm_add), channel_id, user_id, access_token, nick}; +} + +awaitable cluster::co_gdm_remove(snowflake channel_id, snowflake user_id) { + return {this, static_cast(&cluster::gdm_remove), channel_id, user_id}; +} + +awaitable cluster::co_guild_emoji_create(snowflake guild_id, const class emoji& newemoji) { + return {this, static_cast(&cluster::guild_emoji_create), guild_id, newemoji}; +} + +awaitable cluster::co_guild_emoji_delete(snowflake guild_id, snowflake emoji_id) { + return {this, static_cast(&cluster::guild_emoji_delete), guild_id, emoji_id}; +} + +awaitable cluster::co_guild_emoji_edit(snowflake guild_id, const class emoji& newemoji) { + return {this, static_cast(&cluster::guild_emoji_edit), guild_id, newemoji}; +} + +awaitable cluster::co_guild_emoji_get(snowflake guild_id, snowflake emoji_id) { + return {this, static_cast(&cluster::guild_emoji_get), guild_id, emoji_id}; +} + +awaitable cluster::co_guild_emojis_get(snowflake guild_id) { + return {this, static_cast(&cluster::guild_emojis_get), guild_id}; +} + +awaitable cluster::co_get_gateway_bot() { + return {this, static_cast(&cluster::get_gateway_bot)}; +} + +awaitable cluster::co_guild_current_member_edit(snowflake guild_id, const std::string &nickname) { + return {this, static_cast(&cluster::guild_current_member_edit), guild_id, nickname}; +} + +awaitable cluster::co_guild_auditlog_get(snowflake guild_id, snowflake user_id, uint32_t action_type, snowflake before, snowflake after, uint32_t limit) { + return {this, static_cast(&cluster::guild_auditlog_get), guild_id, user_id, action_type, before, after, limit}; +} + +awaitable cluster::co_guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t delete_message_seconds) { + return {this, static_cast(&cluster::guild_ban_add), guild_id, user_id, delete_message_seconds}; +} + +awaitable cluster::co_guild_ban_delete(snowflake guild_id, snowflake user_id) { + return {this, static_cast(&cluster::guild_ban_delete), guild_id, user_id}; +} + +awaitable cluster::co_guild_create(const class guild &g) { + return {this, static_cast(&cluster::guild_create), g}; +} + +awaitable cluster::co_guild_delete(snowflake guild_id) { + return {this, static_cast(&cluster::guild_delete), guild_id}; +} + +awaitable cluster::co_guild_delete_integration(snowflake guild_id, snowflake integration_id) { + return {this, static_cast(&cluster::guild_delete_integration), guild_id, integration_id}; +} + +awaitable cluster::co_guild_edit(const class guild &g) { + return {this, static_cast(&cluster::guild_edit), g}; +} + +awaitable cluster::co_guild_edit_widget(snowflake guild_id, const class guild_widget &gw) { + return {this, static_cast(&cluster::guild_edit_widget), guild_id, gw}; +} + +awaitable cluster::co_guild_get_ban(snowflake guild_id, snowflake user_id) { + return {this, static_cast(&cluster::guild_get_ban), guild_id, user_id}; +} + +awaitable cluster::co_guild_get_bans(snowflake guild_id, snowflake before, snowflake after, snowflake limit) { + return {this, static_cast(&cluster::guild_get_bans), guild_id, before, after, limit}; +} + +awaitable cluster::co_guild_get(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get), guild_id}; +} + +awaitable cluster::co_guild_get_integrations(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get_integrations), guild_id}; +} + +awaitable cluster::co_guild_get_preview(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get_preview), guild_id}; +} + +awaitable cluster::co_guild_get_vanity(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get_vanity), guild_id}; +} + +awaitable cluster::co_guild_get_widget(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get_widget), guild_id}; +} + +awaitable cluster::co_guild_modify_integration(snowflake guild_id, const class integration &i) { + return {this, static_cast(&cluster::guild_modify_integration), guild_id, i}; +} + +awaitable cluster::co_guild_get_prune_counts(snowflake guild_id, const struct prune& pruneinfo) { + return {this, static_cast(&cluster::guild_get_prune_counts), guild_id, pruneinfo}; +} + +awaitable cluster::co_guild_begin_prune(snowflake guild_id, const struct prune& pruneinfo) { + return {this, static_cast(&cluster::guild_begin_prune), guild_id, pruneinfo}; +} + +awaitable cluster::co_guild_set_nickname(snowflake guild_id, const std::string &nickname) { + return {this, static_cast(&cluster::guild_set_nickname), guild_id, nickname}; +} + +awaitable cluster::co_guild_sync_integration(snowflake guild_id, snowflake integration_id) { + return {this, static_cast(&cluster::guild_sync_integration), guild_id, integration_id}; +} + +awaitable cluster::co_guild_add_member(const guild_member& gm, const std::string &access_token) { + return {this, static_cast(&cluster::guild_add_member), gm, access_token}; +} + +awaitable cluster::co_guild_edit_member(const guild_member& gm) { + return {this, static_cast(&cluster::guild_edit_member), gm}; +} + +awaitable cluster::co_guild_get_member(snowflake guild_id, snowflake user_id) { + return {this, static_cast(&cluster::guild_get_member), guild_id, user_id}; +} + +awaitable cluster::co_guild_get_members(snowflake guild_id, uint16_t limit, snowflake after) { + return {this, static_cast(&cluster::guild_get_members), guild_id, limit, after}; +} + +awaitable cluster::co_guild_member_add_role(snowflake guild_id, snowflake user_id, snowflake role_id) { + return {this, static_cast(&cluster::guild_member_add_role), guild_id, user_id, role_id}; +} + +awaitable cluster::co_guild_member_delete(snowflake guild_id, snowflake user_id) { + return {this, static_cast(&cluster::guild_member_delete), guild_id, user_id}; +} + +awaitable cluster::co_guild_member_kick(snowflake guild_id, snowflake user_id) { + return {this, static_cast(&cluster::guild_member_kick), guild_id, user_id}; +} + +awaitable cluster::co_guild_member_timeout(snowflake guild_id, snowflake user_id, time_t communication_disabled_until) { + return {this, static_cast(&cluster::guild_member_timeout), guild_id, user_id, communication_disabled_until}; +} + +awaitable cluster::co_guild_member_delete_role(snowflake guild_id, snowflake user_id, snowflake role_id) { + return {this, static_cast(&cluster::guild_member_delete_role), guild_id, user_id, role_id}; +} + +awaitable cluster::co_guild_member_remove_role(snowflake guild_id, snowflake user_id, snowflake role_id) { + return {this, static_cast(&cluster::guild_member_remove_role), guild_id, user_id, role_id}; +} + +awaitable cluster::co_guild_member_move(const snowflake channel_id, const snowflake guild_id, const snowflake user_id) { + return {this, static_cast(&cluster::guild_member_move), channel_id, guild_id, user_id}; +} + +awaitable cluster::co_guild_search_members(snowflake guild_id, const std::string& query, uint16_t limit) { + return {this, static_cast(&cluster::guild_search_members), guild_id, query, limit}; +} + +awaitable cluster::co_guild_get_invites(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get_invites), guild_id}; +} + +awaitable cluster::co_invite_delete(const std::string &invitecode) { + return {this, static_cast(&cluster::invite_delete), invitecode}; +} + +awaitable cluster::co_invite_get(const std::string &invite_code) { + return {this, static_cast(&cluster::invite_get), invite_code}; +} + +awaitable cluster::co_message_add_reaction(const struct message &m, const std::string &reaction) { + return {this, static_cast(&cluster::message_add_reaction), m, reaction}; +} + +awaitable cluster::co_message_add_reaction(snowflake message_id, snowflake channel_id, const std::string &reaction) { + return {this, static_cast(&cluster::message_add_reaction), message_id, channel_id, reaction}; +} + +awaitable cluster::co_message_create(const message &m) { + return {this, static_cast(&cluster::message_create), m}; +} + +awaitable cluster::co_message_crosspost(snowflake message_id, snowflake channel_id) { + return {this, static_cast(&cluster::message_crosspost), message_id, channel_id}; +} + +awaitable cluster::co_message_delete_all_reactions(const struct message &m) { + return {this, static_cast(&cluster::message_delete_all_reactions), m}; +} + +awaitable cluster::co_message_delete_all_reactions(snowflake message_id, snowflake channel_id) { + return {this, static_cast(&cluster::message_delete_all_reactions), message_id, channel_id}; +} + +awaitable cluster::co_message_delete_bulk(const std::vector& message_ids, snowflake channel_id) { + return {this, static_cast&, snowflake, command_completion_event_t)>(&cluster::message_delete_bulk), message_ids, channel_id}; +} + +awaitable cluster::co_message_delete(snowflake message_id, snowflake channel_id) { + return {this, static_cast(&cluster::message_delete), message_id, channel_id}; +} + +awaitable cluster::co_message_delete_own_reaction(const struct message &m, const std::string &reaction) { + return {this, static_cast(&cluster::message_delete_own_reaction), m, reaction}; +} + +awaitable cluster::co_message_delete_own_reaction(snowflake message_id, snowflake channel_id, const std::string &reaction) { + return {this, static_cast(&cluster::message_delete_own_reaction), message_id, channel_id, reaction}; +} + +awaitable cluster::co_message_delete_reaction(const struct message &m, snowflake user_id, const std::string &reaction) { + return {this, static_cast(&cluster::message_delete_reaction), m, user_id, reaction}; +} + +awaitable cluster::co_message_delete_reaction(snowflake message_id, snowflake channel_id, snowflake user_id, const std::string &reaction) { + return {this, static_cast(&cluster::message_delete_reaction), message_id, channel_id, user_id, reaction}; +} + +awaitable cluster::co_message_delete_reaction_emoji(const struct message &m, const std::string &reaction) { + return {this, static_cast(&cluster::message_delete_reaction_emoji), m, reaction}; +} + +awaitable cluster::co_message_delete_reaction_emoji(snowflake message_id, snowflake channel_id, const std::string &reaction) { + return {this, static_cast(&cluster::message_delete_reaction_emoji), message_id, channel_id, reaction}; +} + +awaitable cluster::co_message_edit(const message &m) { + return {this, static_cast(&cluster::message_edit), m}; +} + +awaitable cluster::co_message_get(snowflake message_id, snowflake channel_id) { + return {this, static_cast(&cluster::message_get), message_id, channel_id}; +} + +awaitable cluster::co_message_get_reactions(const struct message &m, const std::string &reaction, snowflake before, snowflake after, snowflake limit) { + return {this, static_cast(&cluster::message_get_reactions), m, reaction, before, after, limit}; +} + +awaitable cluster::co_message_get_reactions(snowflake message_id, snowflake channel_id, const std::string &reaction, snowflake before, snowflake after, snowflake limit) { + return {this, static_cast(&cluster::message_get_reactions), message_id, channel_id, reaction, before, after, limit}; +} + +awaitable cluster::co_message_pin(snowflake channel_id, snowflake message_id) { + return {this, static_cast(&cluster::message_pin), channel_id, message_id}; +} + +awaitable cluster::co_messages_get(snowflake channel_id, snowflake around, snowflake before, snowflake after, uint64_t limit) { + return {this, static_cast(&cluster::messages_get), channel_id, around, before, after, limit}; +} + +awaitable cluster::co_message_unpin(snowflake channel_id, snowflake message_id) { + return {this, static_cast(&cluster::message_unpin), channel_id, message_id}; +} + +awaitable cluster::co_channel_pins_get(snowflake channel_id) { + return {this, static_cast(&cluster::channel_pins_get), channel_id}; +} + +awaitable cluster::co_role_create(const class role &r) { + return {this, static_cast(&cluster::role_create), r}; +} + +awaitable cluster::co_role_delete(snowflake guild_id, snowflake role_id) { + return {this, static_cast(&cluster::role_delete), guild_id, role_id}; +} + +awaitable cluster::co_role_edit(const class role &r) { + return {this, static_cast(&cluster::role_edit), r}; +} + +awaitable cluster::co_roles_edit_position(snowflake guild_id, const std::vector &roles) { + return {this, static_cast &, command_completion_event_t)>(&cluster::roles_edit_position), guild_id, roles}; +} + +awaitable cluster::co_roles_get(snowflake guild_id) { + return {this, static_cast(&cluster::roles_get), guild_id}; +} + +awaitable cluster::co_application_role_connection_get(snowflake application_id) { + return {this, static_cast(&cluster::application_role_connection_get), application_id}; +} + +awaitable cluster::co_application_role_connection_update(snowflake application_id, const std::vector &connection_metadata) { + return {this, static_cast &, command_completion_event_t)>(&cluster::application_role_connection_update), application_id, connection_metadata}; +} + +awaitable cluster::co_user_application_role_connection_get(snowflake application_id) { + return {this, static_cast(&cluster::user_application_role_connection_get), application_id}; +} + +awaitable cluster::co_user_application_role_connection_update(snowflake application_id, const application_role_connection &connection) { + return {this, static_cast(&cluster::user_application_role_connection_update), application_id, connection}; +} + +awaitable cluster::co_guild_events_get(snowflake guild_id) { + return {this, static_cast(&cluster::guild_events_get), guild_id}; +} + +awaitable cluster::co_guild_event_create(const scheduled_event& event) { + return {this, static_cast(&cluster::guild_event_create), event}; +} + +awaitable cluster::co_guild_event_delete(snowflake event_id, snowflake guild_id) { + return {this, static_cast(&cluster::guild_event_delete), event_id, guild_id}; +} + +awaitable cluster::co_guild_event_edit(const scheduled_event& event) { + return {this, static_cast(&cluster::guild_event_edit), event}; +} + +awaitable cluster::co_guild_event_get(snowflake guild_id, snowflake event_id) { + return {this, static_cast(&cluster::guild_event_get), guild_id, event_id}; +} + +awaitable cluster::co_stage_instance_create(const stage_instance& si) { + return {this, static_cast(&cluster::stage_instance_create), si}; +} + +awaitable cluster::co_stage_instance_get(const snowflake channel_id) { + return {this, static_cast(&cluster::stage_instance_get), channel_id}; +} + +awaitable cluster::co_stage_instance_edit(const stage_instance& si) { + return {this, static_cast(&cluster::stage_instance_edit), si}; +} + +awaitable cluster::co_stage_instance_delete(const snowflake channel_id) { + return {this, static_cast(&cluster::stage_instance_delete), channel_id}; +} + +awaitable cluster::co_guild_sticker_create(sticker &s) { + return {this, static_cast(&cluster::guild_sticker_create), s}; +} + +awaitable cluster::co_guild_sticker_delete(snowflake sticker_id, snowflake guild_id) { + return {this, static_cast(&cluster::guild_sticker_delete), sticker_id, guild_id}; +} + +awaitable cluster::co_guild_sticker_get(snowflake id, snowflake guild_id) { + return {this, static_cast(&cluster::guild_sticker_get), id, guild_id}; +} + +awaitable cluster::co_guild_sticker_modify(sticker &s) { + return {this, static_cast(&cluster::guild_sticker_modify), s}; +} + +awaitable cluster::co_guild_stickers_get(snowflake guild_id) { + return {this, static_cast(&cluster::guild_stickers_get), guild_id}; +} + +awaitable cluster::co_nitro_sticker_get(snowflake id) { + return {this, static_cast(&cluster::nitro_sticker_get), id}; +} + +awaitable cluster::co_sticker_packs_get() { + return {this, static_cast(&cluster::sticker_packs_get)}; +} + +awaitable cluster::co_guild_create_from_template(const std::string &code, const std::string &name) { + return {this, static_cast(&cluster::guild_create_from_template), code, name}; +} + +awaitable cluster::co_guild_template_create(snowflake guild_id, const std::string &name, const std::string &description) { + return {this, static_cast(&cluster::guild_template_create), guild_id, name, description}; +} + +awaitable cluster::co_guild_template_delete(snowflake guild_id, const std::string &code) { + return {this, static_cast(&cluster::guild_template_delete), guild_id, code}; +} + +awaitable cluster::co_guild_template_modify(snowflake guild_id, const std::string &code, const std::string &name, const std::string &description) { + return {this, static_cast(&cluster::guild_template_modify), guild_id, code, name, description}; +} + +awaitable cluster::co_guild_templates_get(snowflake guild_id) { + return {this, static_cast(&cluster::guild_templates_get), guild_id}; +} + +awaitable cluster::co_guild_template_sync(snowflake guild_id, const std::string &code) { + return {this, static_cast(&cluster::guild_template_sync), guild_id, code}; +} + +awaitable cluster::co_template_get(const std::string &code) { + return {this, static_cast(&cluster::template_get), code}; +} + +awaitable cluster::co_current_user_join_thread(snowflake thread_id) { + return {this, static_cast(&cluster::current_user_join_thread), thread_id}; +} + +awaitable cluster::co_current_user_leave_thread(snowflake thread_id) { + return {this, static_cast(&cluster::current_user_leave_thread), thread_id}; +} + +awaitable cluster::co_threads_get_active(snowflake guild_id) { + return {this, static_cast(&cluster::threads_get_active), guild_id}; +} + +awaitable cluster::co_threads_get_joined_private_archived(snowflake channel_id, snowflake before_id, uint16_t limit) { + return {this, static_cast(&cluster::threads_get_joined_private_archived), channel_id, before_id, limit}; +} + +awaitable cluster::co_threads_get_private_archived(snowflake channel_id, time_t before_timestamp, uint16_t limit) { + return {this, static_cast(&cluster::threads_get_private_archived), channel_id, before_timestamp, limit}; +} + +awaitable cluster::co_threads_get_public_archived(snowflake channel_id, time_t before_timestamp, uint16_t limit) { + return {this, static_cast(&cluster::threads_get_public_archived), channel_id, before_timestamp, limit}; +} + +awaitable cluster::co_thread_member_get(const snowflake thread_id, const snowflake user_id) { + return {this, static_cast(&cluster::thread_member_get), thread_id, user_id}; +} + +awaitable cluster::co_thread_members_get(snowflake thread_id) { + return {this, static_cast(&cluster::thread_members_get), thread_id}; +} + +awaitable cluster::co_thread_create_in_forum(const std::string& thread_name, snowflake channel_id, const message& msg, auto_archive_duration_t auto_archive_duration, uint16_t rate_limit_per_user, std::vector applied_tags) { + return {this, static_cast, command_completion_event_t)>(&cluster::thread_create_in_forum), thread_name, channel_id, msg, auto_archive_duration, rate_limit_per_user, applied_tags}; +} + +awaitable cluster::co_thread_create(const std::string& thread_name, snowflake channel_id, uint16_t auto_archive_duration, channel_type thread_type, bool invitable, uint16_t rate_limit_per_user) { + return {this, static_cast(&cluster::thread_create), thread_name, channel_id, auto_archive_duration, thread_type, invitable, rate_limit_per_user}; +} + +awaitable cluster::co_thread_edit(const thread &t) { + return {this, static_cast(&cluster::thread_edit), t}; +} + +awaitable cluster::co_thread_create_with_message(const std::string& thread_name, snowflake channel_id, snowflake message_id, uint16_t auto_archive_duration, uint16_t rate_limit_per_user) { + return {this, static_cast(&cluster::thread_create_with_message), thread_name, channel_id, message_id, auto_archive_duration, rate_limit_per_user}; +} + +awaitable cluster::co_thread_member_add(snowflake thread_id, snowflake user_id) { + return {this, static_cast(&cluster::thread_member_add), thread_id, user_id}; +} + +awaitable cluster::co_thread_member_remove(snowflake thread_id, snowflake user_id) { + return {this, static_cast(&cluster::thread_member_remove), thread_id, user_id}; +} + +awaitable cluster::co_current_user_edit(const std::string &nickname, const std::string& image_blob, const image_type type) { + return {this, static_cast(&cluster::current_user_edit), nickname, image_blob, type}; +} + +awaitable cluster::co_current_application_get() { + return {this, static_cast(&cluster::current_application_get)}; +} + +awaitable cluster::co_current_user_get() { + return {this, static_cast(&cluster::current_user_get)}; +} + +awaitable cluster::co_current_user_set_voice_state(snowflake guild_id, snowflake channel_id, bool suppress, time_t request_to_speak_timestamp) { + return {this, static_cast(&cluster::current_user_set_voice_state), guild_id, channel_id, suppress, request_to_speak_timestamp}; +} + +awaitable cluster::co_user_set_voice_state(snowflake user_id, snowflake guild_id, snowflake channel_id, bool suppress) { + return {this, static_cast(&cluster::user_set_voice_state), user_id, guild_id, channel_id, suppress}; +} + +awaitable cluster::co_current_user_connections_get() { + return {this, static_cast(&cluster::current_user_connections_get)}; +} + +awaitable cluster::co_current_user_get_guilds() { + return {this, static_cast(&cluster::current_user_get_guilds)}; +} + +awaitable cluster::co_current_user_leave_guild(snowflake guild_id) { + return {this, static_cast(&cluster::current_user_leave_guild), guild_id}; +} + +awaitable cluster::co_user_get(snowflake user_id) { + return {this, static_cast(&cluster::user_get), user_id}; +} + +awaitable cluster::co_user_get_cached(snowflake user_id) { + return {this, static_cast(&cluster::user_get_cached), user_id}; +} + +awaitable cluster::co_get_voice_regions() { + return {this, static_cast(&cluster::get_voice_regions)}; +} + +awaitable cluster::co_guild_get_voice_regions(snowflake guild_id) { + return {this, static_cast(&cluster::guild_get_voice_regions), guild_id}; +} + +awaitable cluster::co_create_webhook(const class webhook &w) { + return {this, static_cast(&cluster::create_webhook), w}; +} + +awaitable cluster::co_delete_webhook(snowflake webhook_id) { + return {this, static_cast(&cluster::delete_webhook), webhook_id}; +} + +awaitable cluster::co_delete_webhook_message(const class webhook &wh, snowflake message_id, snowflake thread_id) { + return {this, static_cast(&cluster::delete_webhook_message), wh, message_id, thread_id}; +} + +awaitable cluster::co_delete_webhook_with_token(snowflake webhook_id, const std::string &token) { + return {this, static_cast(&cluster::delete_webhook_with_token), webhook_id, token}; +} + +awaitable cluster::co_edit_webhook(const class webhook& wh) { + return {this, static_cast(&cluster::edit_webhook), wh}; +} + +awaitable cluster::co_edit_webhook_message(const class webhook &wh, const struct message& m, snowflake thread_id) { + return {this, static_cast(&cluster::edit_webhook_message), wh, m, thread_id}; +} + +awaitable cluster::co_edit_webhook_with_token(const class webhook& wh) { + return {this, static_cast(&cluster::edit_webhook_with_token), wh}; +} + +awaitable cluster::co_execute_webhook(const class webhook &wh, const struct message& m, bool wait, snowflake thread_id, const std::string& thread_name) { + return {this, static_cast(&cluster::execute_webhook), wh, m, wait, thread_id, thread_name}; +} + +awaitable cluster::co_get_channel_webhooks(snowflake channel_id) { + return {this, static_cast(&cluster::get_channel_webhooks), channel_id}; +} + +awaitable cluster::co_get_guild_webhooks(snowflake guild_id) { + return {this, static_cast(&cluster::get_guild_webhooks), guild_id}; +} + +awaitable cluster::co_get_webhook(snowflake webhook_id) { + return {this, static_cast(&cluster::get_webhook), webhook_id}; +} + +awaitable cluster::co_get_webhook_message(const class webhook &wh, snowflake message_id, snowflake thread_id) { + return {this, static_cast(&cluster::get_webhook_message), wh, message_id, thread_id}; +} + +awaitable cluster::co_get_webhook_with_token(snowflake webhook_id, const std::string &token) { + return {this, static_cast(&cluster::get_webhook_with_token), webhook_id, token}; +} + + +}; + +/* End of auto-generated definitions */ +dpp::awaitable dpp::cluster::co_request(const std::string &url, http_method method, const std::string &postdata, const std::string &mimetype, const std::multimap &headers) { + return awaitable{[&](auto &&cc) { this->request(url, method, cc, postdata, mimetype, headers); }}; +} + +#endif