Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #45

Merged
merged 27 commits into from
Jan 8, 2023
Merged

Dev #45

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
86e927b
feat: added support for application role connection metadata
Commandserver Dec 15, 2022
3dd48b1
Merge branch 'dev' into master
braindigitalis Dec 15, 2022
ea31efc
feat: support for default forum layout
Commandserver Dec 15, 2022
71faf7f
Merge branch 'dev' into dev
braindigitalis Dec 16, 2022
23930ea
updated docs of interaction class
Commandserver Dec 17, 2022
347119f
Merge remote-tracking branch 'origin/dev' into dev
Commandserver Dec 17, 2022
5061e02
docs: updated docs of scheduled_event::set_status
Commandserver Dec 17, 2022
7688c0b
one line comment
Commandserver Dec 17, 2022
851f2b2
fix channel bitrate parsing on channel bitrates over 65 kbits (#587)
Commandserver Dec 18, 2022
08d5daa
feat: support for default forum layout (#586)
braindigitalis Dec 18, 2022
0c06cba
feat: support for age restricted commands (#588)
braindigitalis Dec 18, 2022
7d2ef88
added map typedef for application_role_connection_metadata
Commandserver Dec 18, 2022
e86294b
updated application role connection feature & added `rest_request_vec…
Commandserver Dec 26, 2022
3fde64b
make metadata in role connection optional
Commandserver Dec 27, 2022
3d2c6bc
build(deps): bump doxygen-awesome-css from `e829184` to `f8dc902`
dependabot[bot] Jan 3, 2023
c62fa13
build(deps): bump doxygen-awesome-css from `e829184` to `f8dc902` (#589)
braindigitalis Jan 3, 2023
ab47438
feat: added support for application role connection metadata (#584)
braindigitalis Jan 3, 2023
350c00f
Fix cluster sync calls for subscription calls
braindigitalis Jan 4, 2023
e73de38
fix(cmake): Use standard install dirs on Linux
NexAdn Jan 4, 2023
2a50784
fix(cmake): Fix included file name in libdpp-config.cmake
NexAdn Jan 4, 2023
ad31d3c
Fixes to the DPP installlation on Linux (#591)
braindigitalis Jan 4, 2023
52eb3f1
fixes to libdpp-config
braindigitalis Jan 4, 2023
2c9f487
Merge branch 'dev' of github.com:brainboxdotcc/DPP into dev
braindigitalis Jan 4, 2023
b9eb418
fix comment about libdpp->dpp
braindigitalis Jan 4, 2023
364174c
[bot] VCPKG info update [skip ci]
braindigitalis Jan 4, 2023
aa3db52
attempt to fix cpack for win32
braindigitalis Jan 4, 2023
02a16bc
Merge branch 'dev' of github.com:brainboxdotcc/DPP
braindigitalis Jan 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"xmake",
"CORO",
"cback",
"mentionables"
"mentionables",
"stringified"
],
"flagWords": [
"hte"
Expand Down
2 changes: 2 additions & 0 deletions buildtools/make_struct.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
'message_delete_own_reaction',
'message_get_reactions',
'channel_typing',
'application_role_connection_get', // TODO: rest_request_vector
'application_role_connection_update',
];

/* The script cannot determine the correct return type of these methods,
Expand Down
28 changes: 19 additions & 9 deletions cmake/CPackSetup.cmake
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
include(GNUInstallDirs)
set(DPP_EXPORT_NAME dpp)
set(DPP_VERSIONED ${DPP_EXPORT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
set(DPP_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${DPP_EXPORT_NAME})
set(DPP_VERSION_FILE ${PROJECT_BINARY_DIR}/${DPP_EXPORT_NAME}-config-version.cmake)

# The three lines below are only used for windows builds
set(DPP_VERSIONED ${DPP_EXPORT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
set(DPP_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${DPP_VERSIONED})
set(DPP_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}/${DPP_VERSIONED})


## Pack the binary output
install(TARGETS dpp
if (WIN32)
install(TARGETS dpp
EXPORT ${DPP_EXPORT_NAME}
LIBRARY DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${DPP_INSTALL_INCLUDE_DIR})
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION "${DPP_INSTALL_INCLUDE_DIR}")
else()
install(TARGETS dpp
EXPORT ${DPP_EXPORT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR})
endif()

## Allow for a specific version to be chosen in the `find_package` command
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${DPP_VERSION_FILE}
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

## Package the include headers (the trailing slash is important, otherwise
## the include folder will be copied, instead of it's contents)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION "${DPP_INSTALL_INCLUDE_DIR}")

## Include the file which allows `find_package(libdpp)` to function.
install(FILES "${CMAKE_SOURCE_DIR}/cmake/libdpp-config.cmake" "${DPP_VERSION_FILE}" DESTINATION "${DPP_INSTALL_LIBRARY_DIR}")
## Include the file which allows `find_package(dpp)` to function.
install(FILES "${CMAKE_SOURCE_DIR}/cmake/dpp-config.cmake" "${DPP_VERSION_FILE}" DESTINATION "${DPP_CMAKE_DIR}")

## Export the targets to allow other projects to easily include this project
install(EXPORT "${DPP_EXPORT_NAME}" DESTINATION "${DPP_INSTALL_LIBRARY_DIR}" NAMESPACE dpp::)
install(EXPORT "${DPP_EXPORT_NAME}" DESTINATION "${DPP_CMAKE_DIR}" NAMESPACE dpp::)

# Prepare information for packaging into .zip, .deb, .rpm
## Project installation metadata
Expand Down
6 changes: 3 additions & 3 deletions cmake/libdpp-config.cmake → cmake/dpp-config.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# libdpp-config.cmake - package configuration file
# dpp-config.cmake - package configuration file

## Get current filesystem path (will a prefixed by where this package was installed)
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

## Use this directory to include libdpp which has the rest of the project targets
include(${SELF_DIR}/libdpp.cmake)
## Use this directory to include dpp which has the rest of the project targets
include(${SELF_DIR}/dpp.cmake)

## Set OpenSSl directory for macos. It is also in our main CMakeLists.txt, but this file is independent from that.
if(APPLE)
Expand Down
2 changes: 1 addition & 1 deletion doxygen-awesome-css
4 changes: 2 additions & 2 deletions include/dpp/appcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,15 +722,15 @@ class DPP_EXPORT interaction : public managed, public json_interface<interaction
* @brief Get the channel this command originated on
*
* @return const dpp::channel& channel
* @throws dpp::logic_error Command originated from a DM or channel not in cache
* @throws dpp::logic_exception Command originated from a DM or channel not in cache
*/
const dpp::channel& get_channel() const;

/**
* @brief Get the guild this command originated on
*
* @return const dpp::guild& guild
* @throws dpp::logic_error Command originated from a DM or guild not in cache
* @throws dpp::logic_exception Command originated from a DM or guild not in cache
*/
const dpp::guild& get_guild() const;

Expand Down
1 change: 1 addition & 0 deletions include/dpp/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class DPP_EXPORT application : public managed, public json_interface<application
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

/** Constructor */
application();
Expand Down
25 changes: 25 additions & 0 deletions include/dpp/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ enum channel_flags : uint16_t {
c_pinned_thread = 0b0000000010000000,
/// Whether a tag is required to be specified when creating a thread in a forum channel. Tags are specified in the thread::applied_tags field.
c_require_tag = 0b0000000100000000,
/* Note that the 9th and 10th bit are used for the forum layout type */
};

/**
Expand All @@ -97,6 +98,15 @@ enum default_forum_sort_order_t : uint8_t {
so_creation_date = 1,
};

/**
* @brief Types of forum layout views that indicates how the threads in a forum channel will be displayed for users by default
*/
enum forum_layout_type : uint8_t {
fl_not_set = 0, //!< No default has been set for the forum channel
fl_list_view = 1, //!< Display posts as a list
fl_gallery_view = 2, //!< Display posts as a collection of tiles
};

/**
* @brief channel permission overwrite types
*/
Expand Down Expand Up @@ -386,6 +396,14 @@ class DPP_EXPORT channel : public managed, public json_interface<channel> {
*/
channel& set_type(channel_type type);

/**
* @brief Set the default forum layout type for the forum channel
*
* @param layout_type The layout type
* @return Reference to self, so these method calls may be chained
*/
channel& set_default_forum_layout(forum_layout_type layout_type);

/**
* @brief Set flags for this channel object
*
Expand Down Expand Up @@ -494,6 +512,13 @@ class DPP_EXPORT channel : public managed, public json_interface<channel> {
*/
channel_type get_type() const;

/**
* @brief Get the default forum layout type used to display posts in forum channels
*
* @return forum_layout_types Forum layout type
*/
forum_layout_type get_default_forum_layout() const;

/**
* @brief Get the mention ping for the channel
*
Expand Down
49 changes: 46 additions & 3 deletions include/dpp/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -2751,6 +2751,49 @@ class DPP_EXPORT cluster {
*/
void role_delete(snowflake guild_id, snowflake role_id, command_completion_event_t callback = utility::log_error());

/**
* @brief Get the application's role connection metadata records
*
* @see https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records
* @param application_id The application ID
* @param callback Function to call when the API call completes.
* On success the callback will contain a dpp::application_role_connection_metadata_list 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 application_role_connection_get(snowflake application_id, command_completion_event_t callback);

/**
* @brief Update the application's role connection metadata records
*
* @see https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records
* @param application_id The application ID
* @param connection_metadata The application role connection metadata to update
* @param callback Function to call when the API call completes.
* On success the callback will contain a dpp::application_role_connection_metadata_list 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 An application can have a maximum of 5 metadata records.
*/
void application_role_connection_update(snowflake application_id, const std::vector<application_role_connection_metadata> &connection_metadata, command_completion_event_t callback = utility::log_error());

/**
* @brief Get user application role connection
*
* @see https://discord.com/developers/docs/resources/user#get-user-application-role-connection
* @param application_id The application ID
* @param callback Function to call when the API call completes.
* On success the callback will contain a dpp::application_role_connection 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 user_application_role_connection_get(snowflake application_id, command_completion_event_t callback);

/**
* @brief Update user application role connection
*
* @see https://discord.com/developers/docs/resources/user#update-user-application-role-connection
* @param application_id The application ID
* @param connection The application role connection to update
* @param callback Function to call when the API call completes.
* On success the callback will contain a dpp::application_role_connection 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 user_application_role_connection_update(snowflake application_id, const application_role_connection &connection, command_completion_event_t callback = utility::log_error());

/**
* @brief Get a user by id
*
Expand Down Expand Up @@ -2963,13 +3006,13 @@ class DPP_EXPORT cluster {
void thread_members_get(snowflake thread_id, command_completion_event_t callback);

/**
* @brief Get active threads in a channel (Sorted by ID in descending order)
* @brief Get active threads in a guild (Sorted by ID in descending order)
* @see https://discord.com/developers/docs/topics/threads
* @param channel_id Channel to get active threads for
* @param guild_id Guild to get active threads for
* @param callback Function to call when the API call completes
* On success the callback will contain a dpp::thread_map 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 threads_get_active(snowflake channel_id, command_completion_event_t callback);
void threads_get_active(snowflake guild_id, command_completion_event_t callback);

/**
* @brief Get public archived threads in a channel (Sorted by archive_timestamp in descending order)
Expand Down
35 changes: 32 additions & 3 deletions include/dpp/cluster_sync_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,35 @@ role_map roles_edit_position_sync(snowflake guild_id, const std::vector<role> &r
*/
role_map roles_get_sync(snowflake guild_id);

/**
* @brief Get user application role connection
*
* @see dpp::cluster::user_application_role_connection_get
* @see https://discord.com/developers/docs/resources/user#get-user-application-role-connection
* @param application_id The application ID
* @return application_role_connection returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
application_role_connection user_application_role_connection_get_sync(snowflake application_id);

/**
* @brief Update user application role connection
*
* @see dpp::cluster::user_application_role_connection_update
* @see https://discord.com/developers/docs/resources/user#update-user-application-role-connection
* @param application_id The application ID
* @param connection The application role connection to update
* @return application_role_connection returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
application_role_connection user_application_role_connection_update_sync(snowflake application_id, const application_role_connection &connection);

/**
* @brief Get all scheduled events for a guild
* @see dpp::cluster::guild_events_get
Expand Down Expand Up @@ -1915,17 +1944,17 @@ confirmation current_user_join_thread_sync(snowflake thread_id);
confirmation current_user_leave_thread_sync(snowflake thread_id);

/**
* @brief Get active threads in a channel (Sorted by ID in descending order)
* @brief Get active threads in a guild (Sorted by ID in descending order)
* @see dpp::cluster::threads_get_active
* @see https://discord.com/developers/docs/topics/threads
* @param channel_id Channel to get active threads for
* @param guild_id Guild to get active threads for
* @return thread_map returned object on completion
* \memberof dpp::cluster
* @throw dpp::rest_exception upon failure to execute REST function
* @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.
* Avoid direct use of this function inside an event handler.
*/
thread_map threads_get_active_sync(snowflake channel_id);
thread_map threads_get_active_sync(snowflake guild_id);

/**
* @brief Get private archived threads in a channel which current user has joined (Sorted by ID in descending order)
Expand Down
28 changes: 28 additions & 0 deletions include/dpp/restrequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,33 @@ template<> inline void rest_request_list<voiceregion>(dpp::cluster* c, const cha
});
}

/**
* @brief Templated REST request helper to save on typing (for returned vectors)
*
* @tparam T singular type to return in lambda callback
* @tparam T vector type to return in lambda callback
* @param c calling cluster
* @param basepath base path for API call
* @param major major API function
* @param minor minor API function
* @param method HTTP method
* @param postdata Post data or empty string
* @param callback Callback lambda
*/
template<class T> inline void rest_request_vector(dpp::cluster* c, const char* basepath, const std::string &major, const std::string &minor, http_method method, const std::string& postdata, command_completion_event_t callback) {
c->post_rest(basepath, major, minor, method, postdata, [c, callback](json &j, const http_request_completion_t& http) {
std::vector<T> list;
confirmation_callback_t e(c, confirmation(), http);
if (!e.is_error()) {
for (auto & curr_item : j) {
list.push_back(T().fill_from_json(&curr_item));
}
}
if (callback) {
callback(confirmation_callback_t(c, list, http));
}
});
}


};
2 changes: 2 additions & 0 deletions include/dpp/restresults.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ struct DPP_EXPORT confirmation {
*
*/
typedef std::variant<
application_role_connection,
application_role_connection_metadata_list,
confirmation,
message,
message_map,
Expand Down
Loading