Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
feat, refactor: Added Pin permission, updated pin endpoints
  • Loading branch information
Jaskowicz1 committed Sep 8, 2025
commit c2118a7502c623ab63f979a04c0560e973e8f086
5 changes: 5 additions & 0 deletions include/dpp/permissions.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ enum permissions : uint64_t {
* @brief Allows use of Clyde AI.
*/
p_use_clyde_ai = 0x0000800000000000,

/**
* @brief Allows pinning and unpinning messages
*/
p_pin_messages = 0x0008000000000000,
};

/**
Expand Down
9 changes: 9 additions & 0 deletions include/dpp/role.h
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,15 @@ class DPP_EXPORT role : public managed, public json_interface<role> {
*/
bool has_use_clyde_ai() const;

/**
* @brief True if has permission to use pin messages.
*
* @note Having the administrator permission causes this method to always return true
* Channel specific overrides may apply to permissions.
* @return bool True if user has the Pin Messages permission or is administrator.
*/
bool has_pin_messages() const;

/**
* @brief Get guild members who have this role.
*
Expand Down
6 changes: 3 additions & 3 deletions src/dpp/cluster/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void cluster::message_get_reactions(snowflake message_id, snowflake channel_id,


void cluster::message_pin(snowflake channel_id, snowflake message_id, command_completion_event_t callback) {
rest_request<confirmation>(this, API_PATH "/channels", std::to_string(channel_id), "pins/" + std::to_string(message_id), m_put, "", callback);
rest_request<confirmation>(this, API_PATH "/channels", std::to_string(channel_id), "/messages/pins/" + std::to_string(message_id), m_put, "", std::move(callback));
}

void cluster::messages_get(snowflake channel_id, snowflake around, snowflake before, snowflake after, uint64_t limit, command_completion_event_t callback) {
Expand All @@ -168,7 +168,7 @@ void cluster::messages_get(snowflake channel_id, snowflake around, snowflake bef


void cluster::message_unpin(snowflake channel_id, snowflake message_id, command_completion_event_t callback) {
rest_request<confirmation>(this, API_PATH "/channels", std::to_string(channel_id), "pins/" + std::to_string(message_id), m_delete, "", callback);
rest_request<confirmation>(this, API_PATH "/channels", std::to_string(channel_id), "/messages/pins/" + std::to_string(message_id), m_delete, "", std::move(callback));
}


Expand Down Expand Up @@ -205,7 +205,7 @@ void cluster::poll_end(snowflake message_id, snowflake channel_id, command_compl


void cluster::channel_pins_get(snowflake channel_id, command_completion_event_t callback) {
rest_request_list<message>(this, API_PATH "/channels", std::to_string(channel_id), "pins", m_get, "", callback);
rest_request_list<message>(this, API_PATH "/channels", std::to_string(channel_id), "/messages/pins", m_get, "", std::move(callback));
}

}
4 changes: 4 additions & 0 deletions src/dpp/role.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ bool role::has_use_clyde_ai() const {
return has_administrator() || permissions.has(p_use_clyde_ai);
}

bool role::has_pin_messages() const {
return has_administrator() || permissions.has(p_pin_messages);
}

role& role::set_name(const std::string& n) {
name = utility::validate(n, 1, 100, "Role name too short");
return *this;
Expand Down
Loading