Skip to content

Commit d24beaa

Browse files
committed
feat: Added follow_up and co_follow_up functions and improve docs
1 parent 8293247 commit d24beaa

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed

include/dpp/cluster.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ class DPP_EXPORT cluster {
16501650
void interaction_response_get_original(const std::string &token, command_completion_event_t callback = utility::log_error());
16511651

16521652
/**
1653-
* @brief Create a followup message to a slash command
1653+
* @brief Create a followup message for an interaction
16541654
*
16551655
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
16561656
* @param token Token for the interaction webhook
@@ -1661,7 +1661,7 @@ class DPP_EXPORT cluster {
16611661
void interaction_followup_create(const std::string &token, const message &m, command_completion_event_t callback = utility::log_error());
16621662

16631663
/**
1664-
* @brief Edit original followup message to a slash command
1664+
* @brief Edit original followup message for an interaction
16651665
* This is an alias for cluster::interaction_response_edit
16661666
* @see cluster::interaction_response_edit
16671667
*
@@ -1683,7 +1683,7 @@ class DPP_EXPORT cluster {
16831683
void interaction_followup_delete(const std::string &token, command_completion_event_t callback = utility::log_error());
16841684

16851685
/**
1686-
* @brief Edit followup message to a slash command
1686+
* @brief Edit followup message for an interaction
16871687
* The message ID in the message you pass should be correctly set to that of a followup message you previously sent
16881688
*
16891689
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message
@@ -1695,7 +1695,7 @@ class DPP_EXPORT cluster {
16951695
void interaction_followup_edit(const std::string &token, const message &m, command_completion_event_t callback = utility::log_error());
16961696

16971697
/**
1698-
* @brief Get the followup message to a slash command
1698+
* @brief Get the followup message for an interaction
16991699
*
17001700
* @see https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message
17011701
* @param token Token for the interaction webhook
@@ -1706,7 +1706,7 @@ class DPP_EXPORT cluster {
17061706
void interaction_followup_get(const std::string &token, snowflake message_id, command_completion_event_t callback);
17071707

17081708
/**
1709-
* @brief Get the original followup message to a slash command
1709+
* @brief Get the original followup message for an interaction
17101710
* This is an alias for cluster::interaction_response_get_original
17111711
* @see cluster::interaction_response_get_original
17121712
*

include/dpp/dispatcher.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,22 @@ struct DPP_EXPORT interaction_create_t : public event_dispatch_t {
569569
*/
570570
void reply(const std::string& mt, command_completion_event_t callback = utility::log_error()) const;
571571

572+
/**
573+
* @brief Create a follow-up message for this interaction.
574+
* @param m Message object to send. Not all fields are supported by Discord.
575+
* @param callback User function to execute when the api call completes.
576+
* On success the callback will contain a dpp::confirmation object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
577+
*/
578+
void follow_up(const message& m, command_completion_event_t callback = utility::log_error()) const;
579+
580+
/**
581+
* @brief Create a follow-up message for this interaction.
582+
* @param mt The string value to send, for simple text only messages
583+
* @param callback User function to execute when the api call completes.
584+
* On success the callback will contain a dpp::confirmation object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
585+
*/
586+
void follow_up(const std::string& mt, command_completion_event_t callback = utility::log_error()) const;
587+
572588
/**
573589
* @brief Reply to interaction with a dialog box
574590
*
@@ -681,6 +697,22 @@ struct DPP_EXPORT interaction_create_t : public event_dispatch_t {
681697
*/
682698
dpp::async<dpp::confirmation_callback_t> co_reply(const std::string& mt) const;
683699

700+
/**
701+
* @brief Create a follow-up message for this interaction.
702+
*
703+
* @param m Message object to send. Not all fields are supported by Discord.
704+
* On success the result will contain a dpp::confirmation object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
705+
*/
706+
dpp::async<dpp::confirmation_callback_t> co_follow_up(const message& m) const;
707+
708+
/**
709+
* @brief Create a follow-up message for this interaction.
710+
*
711+
* @param mt The string value to send, for simple text only messages
712+
* On success the result will contain a dpp::confirmation object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
713+
*/
714+
dpp::async<dpp::confirmation_callback_t> co_follow_up(const std::string& mt) const;
715+
684716
/**
685717
* @brief Reply to interaction with a dialog box
686718
*

src/dpp/dispatcher.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ void interaction_create_t::reply(const std::string& mt, command_completion_event
216216
this->reply(ir_channel_message_with_source, dpp::message(this->command.channel_id, mt, mt_application_command), callback);
217217
}
218218

219+
void interaction_create_t::follow_up(const message& m, command_completion_event_t callback) const {
220+
owner->interaction_followup_create(this->command.token, m, std::move(callback));
221+
}
222+
223+
void interaction_create_t::follow_up(const std::string& mt, command_completion_event_t callback) const {
224+
owner->interaction_followup_create(this->command.token, dpp::message(this->command.channel_id, mt, mt_application_command), std::move(callback));
225+
}
226+
219227
void interaction_create_t::edit_response(const message& m, command_completion_event_t callback) const {
220228
owner->interaction_response_edit(this->command.token, m, std::move(callback));
221229
}
@@ -237,7 +245,7 @@ void interaction_create_t::edit_original_response(const message& m, command_comp
237245
std::vector<std::string> file_contents{};
238246
std::vector<std::string> file_mimetypes{};
239247

240-
for(message_file_data data : m.file_data) {
248+
for(const message_file_data& data : m.file_data) {
241249
file_names.push_back(data.name);
242250
file_contents.push_back(data.content);
243251
file_mimetypes.push_back(data.mimetype);
@@ -280,6 +288,14 @@ async<confirmation_callback_t> interaction_create_t::co_reply(const std::string&
280288
return dpp::async{[&, this] <typename T> (T&& cb) { this->reply(mt, std::forward<T>(cb)); }};
281289
}
282290

291+
async<confirmation_callback_t> interaction_create_t::co_follow_up(const message& m) const {
292+
return dpp::async{[&, this] <typename T> (T&& cb) { this->follow_up(m, std::forward<T>(cb)); }};
293+
}
294+
295+
async<confirmation_callback_t> interaction_create_t::co_follow_up(const std::string& mt) const {
296+
return dpp::async{[&, this] <typename T> (T&& cb) { this->follow_up(mt, std::forward<T>(cb)); }};
297+
}
298+
283299
async<confirmation_callback_t> interaction_create_t::co_dialog(const interaction_modal_response& mr) const {
284300
return dpp::async{[&, this] <typename T> (T&& cb) { this->dialog(mr, std::forward<T>(cb)); }};
285301
}

0 commit comments

Comments
 (0)