Skip to content

Commit

Permalink
Merge pull request #273 from Commandserver/i1
Browse files Browse the repository at this point in the history
added stage attribute and fixed stage_instance_get not returning stage instances
  • Loading branch information
braindigitalis authored Feb 13, 2022
2 parents 1bcdbef + 48612f5 commit 1adaee7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ class DPP_EXPORT cluster {
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
* @param invite Invite code to delete
* @param callback Function to call when the API call completes.
* 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().
* On success the callback will contain a dpp::invite 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().
*/
void invite_delete(const std::string &invite, command_completion_event_t callback = {});

Expand Down Expand Up @@ -3065,7 +3065,7 @@ class DPP_EXPORT cluster {
*
* @param instance Stage instance to create
* @param callback User function to execute when the api call completes
* On success the callback will contain a dpp::stage_instance 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().
* 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().
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
*/
void stage_instance_create(const stage_instance& instance, command_completion_event_t callback = {});
Expand Down
4 changes: 4 additions & 0 deletions include/dpp/invite.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <dpp/export.h>
#include <dpp/snowflake.h>
#include <dpp/json_fwd.hpp>
#include <dpp/stage_instance.h>
#include <unordered_map>

namespace dpp {
Expand Down Expand Up @@ -75,6 +76,9 @@ class DPP_EXPORT invite {
* @note Only set when using cluster::channel_invites_get
*/
uint32_t uses;
/** The stage instance data if there is a public stage instance in the stage channel this invite is for
*/
stage_instance stage;

/** Constructor
*/
Expand Down
4 changes: 2 additions & 2 deletions src/dpp/cluster/stage_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ void cluster::stage_instance_create(const stage_instance& si, command_completion
void cluster::stage_instance_get(const snowflake channel_id, command_completion_event_t callback) {
this->post_rest(API_PATH "/stage-instances", std::to_string(channel_id), "", m_get, "", [callback](json &j, const http_request_completion_t& http) {
if (callback) {
callback(confirmation_callback_t("confirmation", stage_instance().fill_from_json(&j), http));
callback(confirmation_callback_t("stage_instance", stage_instance().fill_from_json(&j), http));
}
});
}

void cluster::stage_instance_edit(const stage_instance& si, command_completion_event_t callback) {
this->post_rest(API_PATH "/stage-instances", std::to_string(si.channel_id), "", m_patch, si.build_json(), [callback](json &j, const http_request_completion_t& http) {
if (callback) {
callback(confirmation_callback_t("confirmation", confirmation(), http));
callback(confirmation_callback_t("stage_instance", stage_instance().fill_from_json(&j), http));
}
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/dpp/invite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ invite& invite::fill_from_json(nlohmann::json* j) {
temporary = bool_not_null(j, "temporary");
unique = bool_not_null(j, "unique");
uses = (j->find("uses") != j->end()) ? int32_not_null(j, "uses") : 0;
if (j->find("stage_instance") != j->end()) {
stage = stage_instance().fill_from_json(&((*j)["stage_instance"]));
}
return *this;
}

Expand Down

0 comments on commit 1adaee7

Please sign in to comment.