Skip to content

Commit

Permalink
feat: added setter methods to dpp::invite class
Browse files Browse the repository at this point in the history
  • Loading branch information
Commandserver committed Jun 2, 2023
1 parent 8a952bf commit 6139229
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
48 changes: 48 additions & 0 deletions include/dpp/invite.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,54 @@ class DPP_EXPORT invite : public json_interface<invite> {
*/
virtual ~invite() = default;

/**
* @brief Set the max age after which the invite expires
*
* @param max_age_ The duration in seconds, or 0 for no expiration. Must be between 0 and 604800 (7 days)
* @return invite& reference to self for chaining of calls
*/
invite& set_max_age(const uint32_t max_age_);

/**
* @brief Set the maximum number of uses for this invite
*
* @param max_uses_ Maximum number of uses, or 0 for unlimited. Must be between 0 and 100
* @return invite& reference to self for chaining of calls
*/
invite& set_max_uses(const uint8_t max_uses_);

/**
* @brief Set the target user id
*
* @param user_id The user ID whose stream to display for this voice channel stream invite
* @return invite& reference to self for chaining of calls
*/
invite& set_target_user_id(const snowflake user_id);

/**
* @brief Set the target type for this voice channel invite
*
* @param type invite_target_t Target type
* @return invite& reference to self for chaining of calls
*/
invite& set_target_type(const invite_target_t type);

/**
* @brief Set temporary property of this invite object
*
* @param is_temporary Whether this invite only grants temporary membership
* @return invite& reference to self for chaining of calls
*/
invite& set_temporary(const bool is_temporary);

/**
* @brief Set unique property of this invite object
*
* @param is_unique True if this invite should not replace or "attach to" similar invites
* @return invite& reference to self for chaining of calls
*/
invite& set_unique(const bool is_unique);

/** Read class values from json object
* @param j A json object to read from
* @return A reference to self
Expand Down
30 changes: 30 additions & 0 deletions src/dpp/invite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,34 @@ std::string invite::build_json(bool with_id) const {
return j.dump();
}

invite &invite::set_max_age(const uint32_t max_age_) {
this->max_age = max_age_;
return *this;
}

invite &invite::set_max_uses(const uint8_t max_uses_) {
this->max_uses = max_uses_;
return *this;
}

invite &invite::set_target_user_id(const snowflake user_id) {
this->target_user_id = user_id;
return *this;
}

invite &invite::set_target_type(const invite_target_t type) {
this->target_type = type;
return *this;
}

invite &invite::set_temporary(const bool is_temporary) {
this->temporary = is_temporary;
return *this;
}

invite &invite::set_unique(const bool is_unique) {
this->unique = is_unique;
return *this;
}

};

0 comments on commit 6139229

Please sign in to comment.