|
23 | 23 |
|
24 | 24 | namespace dpp { |
25 | 25 |
|
| 26 | +constexpr uint8_t GET_CHANNEL_PINS_MAX = 50; |
| 27 | + |
26 | 28 | void cluster::message_add_reaction(const struct message &m, const std::string &reaction, command_completion_event_t callback) { |
27 | 29 | rest_request<confirmation>(this, API_PATH "/channels", std::to_string(m.channel_id), "messages/" + std::to_string(m.id) + "/reactions/" + utility::url_encode(reaction) + "/@me", m_put, "", callback); |
28 | 30 | } |
@@ -205,10 +207,25 @@ void cluster::poll_end(snowflake message_id, snowflake channel_id, command_compl |
205 | 207 |
|
206 | 208 |
|
207 | 209 | void cluster::channel_pins_get(snowflake channel_id, command_completion_event_t callback) { |
| 210 | + channel_pins_get(channel_id, {}, {}, callback); |
| 211 | +} |
| 212 | + |
| 213 | +void cluster::channel_pins_get(snowflake channel_id, std::optional<time_t> before, std::optional<uint64_t> limit, command_completion_event_t callback) { |
| 214 | + if (!limit.has_value()) |
| 215 | + { |
| 216 | + limit = GET_CHANNEL_PINS_MAX; |
| 217 | + } |
| 218 | + |
| 219 | + std::string parameters = "messages/pins?limit=" + std::to_string(limit.value()); |
| 220 | + |
| 221 | + if (before.has_value()) { |
| 222 | + parameters.append("&before=" + ts_to_string(before.value())); |
| 223 | + } |
| 224 | + |
208 | 225 | /* Have to do it like this because this now returns more than just a list. |
209 | 226 | * It's now a structure containing the pinned items in "items" and then a boolean called "has_more". |
210 | 227 | */ |
211 | | - this->post_rest_multipart(API_PATH "/channels", std::to_string(channel_id), "messages/pins", m_get, "", [this, callback](json &j, const http_request_completion_t& http) { |
| 228 | + this->post_rest_multipart(API_PATH "/channels", std::to_string(channel_id), parameters, m_get, "", [this, callback](json &j, const http_request_completion_t& http) { |
212 | 229 | std::unordered_map<snowflake, dpp::message_pin> list; |
213 | 230 |
|
214 | 231 | confirmation_callback_t e(this, confirmation(), http); |
|
0 commit comments