Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:brainboxdotcc/DPP
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Oct 19, 2023
2 parents e7f261d + 8b877f9 commit 8e813e8
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 134 deletions.
4 changes: 4 additions & 0 deletions include/dpp/appcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ struct DPP_EXPORT interaction_modal_response : public interaction_response, publ
virtual json to_json_impl(bool with_id = false) const;

public:
using json_interface<interaction_modal_response>::fill_from_json;
using json_interface<interaction_modal_response>::to_json;
using json_interface<interaction_modal_response>::build_json;

/**
* @brief Custom ID for the modal form
*/
Expand Down
64 changes: 43 additions & 21 deletions include/dpp/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <dpp/managed.h>
#include <dpp/utility.h>
#include <dpp/user.h>
#include <dpp/guild.h>
#include <dpp/permissions.h>
#include <dpp/json_fwd.h>
#include <dpp/json_interface.h>
Expand Down Expand Up @@ -127,27 +128,48 @@ class DPP_EXPORT application : public managed, public json_interface<application
application& fill_from_json_impl(nlohmann::json* j);

public:
std::string name; //!< the name of the app
utility::iconhash icon; //!< the icon hash of the app (may be empty)
std::string description; //!< the description of the app
std::string rpc_origins; //!< Optional: an array of rpc origin urls, if rpc is enabled
bool bot_public; //!< when false only app owner can join the app's bot to guilds
bool bot_require_code_grant; //!< when true the app's bot will only join upon completion of the full oauth2 code grant flow
std::string terms_of_service_url; //!< Optional: the url of the app's terms of service
std::string privacy_policy_url; //!< Optional: the url of the app's privacy policy
user owner; //!< Optional: partial user object containing info on the owner of the application
std::string summary; //!< if this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku @deprecated Will be removed in v11
std::string verify_key; //!< the hex encoded key for verification in interactions and the GameSDK's GetTicket
app_team team; //!< if the application belongs to a team, this will be a list of the members of that team (may be empty)
snowflake guild_id; //!< Optional: if this application is a game sold on Discord, this field will be the guild to which it has been linked
snowflake primary_sku_id; //!< Optional: if this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
std::string slug; //!< Optional: if this application is a game sold on Discord, this field will be the URL slug that links to the store page
utility::iconhash cover_image; //!< Optional: the application's default rich presence invite cover image hash
uint32_t flags; //!< Optional: the application's public flags
std::vector<std::string> tags; //!< Up to 5 tags describing the content and functionality of the application
application_install_params install_params; //!< Settings for the application's default in-app authorization link, if enabled
std::string custom_install_url; //!< The application's default custom authorization link, if enabled
std::string role_connections_verification_url; //!< The application's role connection verification entry point, which when configured will render the app as a verification method in the guild role verification configuration
std::string name; //!< the name of the app
utility::iconhash icon; //!< the icon hash of the app (may be empty)
std::string description; //!< the description of the app
std::vector<std::string> rpc_origins; //!< Optional: an array of rpc origin urls, if rpc is enabled
bool bot_public; //!< when false only app owner can join the app's bot to guilds
bool bot_require_code_grant; //!< when true the app's bot will only join upon completion of the full oauth2 code grant flow
user bot; //!< Optional: Partial user object for the bot user associated with the app.
std::string terms_of_service_url; //!< Optional: the url of the app's terms of service
std::string privacy_policy_url; //!< Optional: the url of the app's privacy policy
user owner; //!< Optional: partial user object containing info on the owner of the application
std::string summary; //!< if this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku @deprecated Will be removed in v11
std::string verify_key; //!< the hex encoded key for verification in interactions and the GameSDK's GetTicket
app_team team; //!< if the application belongs to a team, this will be a list of the members of that team (may be empty)
snowflake guild_id; //!< Optional: if this application is a game sold on Discord, this field will be the guild to which it has been linked
guild guild_obj; //!< Optional: Partial object of the associated guild
snowflake primary_sku_id; //!< Optional: if this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
std::string slug; //!< Optional: if this application is a game sold on Discord, this field will be the URL slug that links to the store page
utility::iconhash cover_image; //!< Optional: the application's default rich presence invite cover image hash
uint32_t flags; //!< Optional: the application's public flags
uint64_t approximate_guild_count; //!< Optional: Approximate count of guilds the app has been added to
std::vector<std::string> redirect_uris; //!< Optional: Array of redirect URIs for the app
std::string interactions_endpoint_url; //!< Optional: Interactions endpoint URL for the app
std::string role_connections_verification_url; //!< The application's role connection verification entry point, which when configured will render the app as a verification method in the guild role verification configuration
std::vector<std::string> tags; //!< Up to 5 tags describing the content and functionality of the application
application_install_params install_params; //!< Settings for the application's default in-app authorization link, if enabled
std::string custom_install_url; //!< The application's default custom authorization link, if enabled

uint8_t discoverability_state; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint32_t discovery_eligibility_flags; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint8_t explicit_content_filter; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint8_t creator_monetization_state; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
bool integration_public; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
bool integration_require_code_grant; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
std::vector<std::string> interactions_event_types; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint8_t interactions_version; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
bool is_monetized; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint32_t monetization_eligibility_flags; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint8_t monetization_state; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
bool hook; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint8_t rpc_application_state; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint8_t store_application_state; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.
uint8_t verification_state; //!< @warning This variable is not documented by discord, we have no idea what it means and how it works. Use at your own risk.

/** Constructor */
application();
Expand Down
8 changes: 8 additions & 0 deletions include/dpp/discordevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <dpp/export.h>
#include <dpp/json_fwd.h>
#include <dpp/json_interface.h>
#include <dpp/utility.h>
#include <string_view>
#include <functional>

Expand Down Expand Up @@ -84,6 +85,13 @@ std::string DPP_EXPORT string_not_null(const nlohmann::json* j, const char *keyn
*/
void DPP_EXPORT set_string_not_null(const nlohmann::json* j, const char *keyname, std::string &v);

/** @brief This is a repeat of set_string_not_null, but takes in a iconhash.
* @param j nlohmann::json instance to retrieve value from
* @param keyname key name to check for a value
* @param v Value to change
*/
void DPP_EXPORT set_iconhash_not_null(const nlohmann::json* j, const char *keyname, utility::iconhash &v);

/** @brief Returns a double from a json field value, if defined, else returns 0.
* @param j nlohmann::json instance to retrieve value from
* @param keyname key name to check for a value
Expand Down
104 changes: 55 additions & 49 deletions include/dpp/integration.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <dpp/json_fwd.h>
#include <unordered_map>
#include <dpp/json_interface.h>
#include <dpp/user.h>

namespace dpp {

Expand All @@ -47,34 +48,30 @@ enum integration_type {
* @brief Integration flags
*/
enum integration_flags {
/// Integration enabled
if_enabled = 0b00000001,
/// Integration syncing
if_syncing = 0b00000010,
/// Emoji integration
if_emoticons = 0b00000100,
/// Integration revoked
if_revoked = 0b00001000,
/// Kick users when their subscription expires
if_expire_kick = 0b00010000,
if_enabled = 0b00000001, //!< is this integration enabled
if_syncing = 0b00000010, //!< is this integration syncing @warning This is not provided for discord bot integrations.
if_emoticons = 0b00000100, //!< whether emoticons should be synced for this integration (twitch only currently) @warning This is not provided for discord bot integrations.
if_revoked = 0b00001000, //!< has this integration been revoked @warning This is not provided for discord bot integrations.
if_expire_kick = 0b00010000, //!< kick user when their subscription expires, otherwise only remove the role that is specified by `role_id`. @warning This is not provided for discord bot integrations.
};

/**
* @brief An application that has been integrated
*/
struct DPP_EXPORT integration_app {
/// Integration id
snowflake id;
/// Name
std::string name;
/// Icon
std::string icon;
/// Description
std::string description;
/// Integration summary @deprecated Removed by Discord
std::string summary;
/// Pointer to bot user
class user* bot;
snowflake id; //!< the id of the app
std::string name; //!< the name of the app
utility::iconhash icon; //!< the icon hash of the app
std::string description; //!< the description of the app
class user* bot; //!< the bot associated with this application
};

/**
* @brief The account information for an integration.
*/
struct DPP_EXPORT integration_account {
snowflake id; //!< id of the account
std::string name; //!< name of the account
};

/**
Expand All @@ -97,44 +94,53 @@ class DPP_EXPORT integration : public managed, public json_interface<integration
virtual json to_json_impl(bool with_id = false) const;

public:
/** Integration name */
std::string name;
/** Integration type */
integration_type type;
/** Integration flags from dpp::integration_flags */
uint8_t flags;
/** Role id */
snowflake role_id;
/** User id */
snowflake user_id;
/** The grace period (in days) before expiring subscribers */
uint32_t expire_grace_period;
/** Sync time */
time_t synced_at;
/** Subscriber count */
uint32_t subscriber_count;
/** Account id */
std::string account_id;
/** Account name */
std::string account_name;
/** The bot/OAuth2 application for discord integrations */
integration_app app;
std::string name; //!< integration name
integration_type type; //!< integration type (twitch, youtube, discord, or guild_subscription)
uint8_t flags; //!< integration flags from dpp::integration_flags
snowflake role_id; //!< id that this integration uses for "subscribers" @warning This is not provided for discord bot integrations.
uint32_t expire_grace_period; //!< The grace period (in days) before expiring subscribers @warning This is not provided for discord bot integrations.
user user_obj; //!< user for this integration
integration_account account; //!< integration account information
time_t synced_at; //!< when this integration was last synced @warning This is not provided for discord bot integrations.
uint32_t subscriber_count; //!< how many subscribers this integration has @warning This is not provided for discord bot integrations.
integration_app app; //!< the bot/OAuth2 application for discord integrations
std::vector<std::string> scopes; //!< the scopes the application has been authorized for

/** Default constructor */
integration();

/** Default destructor */
~integration() = default;

/** True if emoticons are enabled */
/**
* Are emoticons enabled for this integration?
* @warning This is not provided for discord bot integrations.
*/
bool emoticons_enabled() const;
/** True if integration is enabled */

/**
* Is the integration enabled?
* @warning This is not provided for discord bot integrations.
*/
bool is_enabled() const;
/** True if is syncing */

/**
* Is the integration syncing?
* @warning This is not provided for discord bot integrations.
*/
bool is_syncing() const;
/** True if has been revoked */

/**
* Has this integration been revoked?
* @warning This is not provided for discord bot integrations.
*/
bool is_revoked() const;
/** True if expiring kicks the user */

/**
* Will the user be kicked if their subscription runs out to the integration?
* If false, the integration will simply remove the role that is specified by `role_id`.
* @warning This is not provided for discord bot integrations.
*/
bool expiry_kicks_user() const;
};

Expand Down
Loading

0 comments on commit 8e813e8

Please sign in to comment.