Skip to content

Commit e5b625b

Browse files
committed
feat: rename voter to vote
1 parent c3345ac commit e5b625b

File tree

6 files changed

+67
-67
lines changed

6 files changed

+67
-67
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -323,31 +323,31 @@ try {
323323
}
324324
```
325325

326-
### Getting your bot's voters
326+
### Getting your bot's votes
327327

328328
#### With C++17 callbacks
329329

330330
```cpp
331331
// First page
332-
client.get_voters([](const auto& result) {
332+
client.get_votes([](const auto& result) {
333333
try {
334-
auto voters = result.get();
334+
auto votes = result.get();
335335

336-
for (auto& voter: voters) {
337-
std::cout << voter.username << std::endl;
336+
for (auto& vote: votes) {
337+
std::cout << vote.username << std::endl;
338338
}
339339
} catch (const std::exception& exc) {
340340
std::cerr << "error: " << exc.what() << std::endl;
341341
}
342342
});
343343

344344
// Subsequent pages
345-
client.get_voters(2, [](const auto& result) {
345+
client.get_votes(2, [](const auto& result) {
346346
try {
347-
auto voters = result.get();
347+
auto votes = result.get();
348348

349-
for (auto& voter: voters) {
350-
std::cout << voter.username << std::endl;
349+
for (auto& vote: votes) {
350+
std::cout << vote.username << std::endl;
351351
}
352352
} catch (const std::exception& exc) {
353353
std::cerr << "error: " << exc.what() << std::endl;
@@ -360,21 +360,21 @@ client.get_voters(2, [](const auto& result) {
360360
```cpp
361361
// First page
362362
try {
363-
const auto voters = co_await client.co_get_voters();
363+
const auto votes = co_await client.co_get_votes();
364364

365-
for (const auto& voter: voters) {
366-
std::cout << voter.username << std::endl;
365+
for (const auto& vote: votes) {
366+
std::cout << vote.username << std::endl;
367367
}
368368
} catch (const std::exception& exc) {
369369
std::cerr << "error: " << exc.what() << std::endl;
370370
}
371371

372372
// Subsequent pages
373373
try {
374-
const auto voters = co_await client.co_get_voters(2);
374+
const auto votes = co_await client.co_get_votes(2);
375375

376-
for (const auto& voter: voters) {
377-
std::cout << voter.username << std::endl;
376+
for (const auto& vote: votes) {
377+
std::cout << vote.username << std::endl;
378378
}
379379
} catch (const std::exception& exc) {
380380
std::cerr << "error: " << exc.what() << std::endl;

include/topgg/client.h

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ namespace topgg {
3535
using get_server_count_completion_event = std::function<void(const result<std::optional<size_t>>&)>;
3636

3737
/**
38-
* @brief The callback function to call when get_voters completes.
38+
* @brief The callback function to call when get_votes completes.
3939
*
40-
* @see topgg::client::get_voters
40+
* @see topgg::client::get_votes
4141
* @since 2.0.0
4242
*/
43-
using get_voters_completion_event = std::function<void(const result<std::vector<voter>>&)>;
43+
using get_votes_completion_event = std::function<void(const result<std::vector<vote>>&)>;
4444

4545
/**
4646
* @brief The callback function to call when has_voted completes.
@@ -326,73 +326,73 @@ namespace topgg {
326326
#endif
327327

328328
/**
329-
* @brief Fetches your Discord bot's recent 100 unique voters.
329+
* @brief Fetches your Discord bot's recent 100 unique votes.
330330
*
331331
* Example:
332332
*
333333
* ```cpp
334334
* dpp::cluster bot{"your bot token"};
335335
* topgg::client client{bot, "your top.gg token"};
336336
*
337-
* client.get_voters(1, [](const auto& result) {
337+
* client.get_votes(1, [](const auto& result) {
338338
* try {
339-
* auto voters = result.get();
339+
* auto votes = result.get();
340340
*
341-
* for (auto& voter: voters) {
342-
* std::cout << voter.username << std::endl;
341+
* for (auto& vote: votes) {
342+
* std::cout << vote.username << std::endl;
343343
* }
344344
* } catch (const std::exception& exc) {
345345
* std::cerr << "error: " << exc.what() << std::endl;
346346
* }
347347
* });
348348
* ```
349349
*
350-
* @param page The page number. Each page can only have at most 100 voters.
351-
* @param callback The callback function to call when get_voters completes.
352-
* @note For its C++20 coroutine counterpart, see co_get_voters.
350+
* @param page The page number. Each page can only have at most 100 votes.
351+
* @param callback The callback function to call when get_votes completes.
352+
* @note For its C++20 coroutine counterpart, see co_get_votes.
353353
* @see topgg::result
354-
* @see topgg::voter
354+
* @see topgg::vote
355355
* @see topgg::client::start_autoposter
356-
* @see topgg::client::co_get_voters
356+
* @see topgg::client::co_get_votes
357357
* @since 2.0.0
358358
*/
359-
void get_voters(size_t page, const get_voters_completion_event& callback);
359+
void get_votes(size_t page, const get_votes_completion_event& callback);
360360

361361
/**
362-
* @brief Fetches your Discord bot's recent 100 unique voters.
362+
* @brief Fetches your Discord bot's recent 100 unique votes.
363363
*
364364
* Example:
365365
*
366366
* ```cpp
367367
* dpp::cluster bot{"your bot token"};
368368
* topgg::client client{bot, "your top.gg token"};
369369
*
370-
* client.get_voters([](const auto& result) {
370+
* client.get_votes([](const auto& result) {
371371
* try {
372-
* auto voters = result.get();
372+
* auto votes = result.get();
373373
*
374-
* for (auto& voter: voters) {
375-
* std::cout << voter.username << std::endl;
374+
* for (auto& vote: votes) {
375+
* std::cout << vote.username << std::endl;
376376
* }
377377
* } catch (const std::exception& exc) {
378378
* std::cerr << "error: " << exc.what() << std::endl;
379379
* }
380380
* });
381381
* ```
382382
*
383-
* @param callback The callback function to call when get_voters completes.
384-
* @note For its C++20 coroutine counterpart, see co_get_voters.
383+
* @param callback The callback function to call when get_votes completes.
384+
* @note For its C++20 coroutine counterpart, see co_get_votes.
385385
* @see topgg::result
386-
* @see topgg::voter
386+
* @see topgg::vote
387387
* @see topgg::client::start_autoposter
388-
* @see topgg::client::co_get_voters
388+
* @see topgg::client::co_get_votes
389389
* @since 2.0.0
390390
*/
391-
void get_voters(const get_voters_completion_event& callback);
391+
void get_votes(const get_votes_completion_event& callback);
392392

393393
#ifdef DPP_CORO
394394
/**
395-
* @brief Fetches your Discord bot's recent 100 unique voters through a C++20 coroutine.
395+
* @brief Fetches your Discord bot's recent 100 unique votes through a C++20 coroutine.
396396
*
397397
* Example:
398398
*
@@ -401,30 +401,30 @@ namespace topgg {
401401
* topgg::client client{bot, "your top.gg token"};
402402
*
403403
* try {
404-
* const auto voters = co_await client.co_get_voters();
404+
* const auto votes = co_await client.co_get_votes();
405405
*
406-
* for (const auto& voter: voters) {
407-
* std::cout << voter.username << std::endl;
406+
* for (const auto& vote: votes) {
407+
* std::cout << vote.username << std::endl;
408408
* }
409409
* } catch (const std::exception& exc) {
410410
* std::cerr << "error: " << exc.what() << std::endl;
411411
* }
412412
* ```
413413
*
414-
* @param page The page number. Each page can only have at most 100 voters. Defaults to 1.
414+
* @param page The page number. Each page can only have at most 100 votes. Defaults to 1.
415415
* @throw topgg::internal_server_error Unexpected error from Top.gg's end.
416416
* @throw topgg::invalid_token Invalid API token.
417417
* @throw topgg::ratelimited Ratelimited from sending more requests.
418418
* @throw dpp::http_error An unexpected HTTP exception has occured.
419-
* @return co_await to retrieve a vector of topgg::voter if successful
420-
* @note For its C++17 callback-based counterpart, see get_voters.
419+
* @return co_await to retrieve a vector of topgg::vote if successful
420+
* @note For its C++17 callback-based counterpart, see get_votes.
421421
* @see topgg::async_result
422-
* @see topgg::voter
422+
* @see topgg::vote
423423
* @see topgg::client::start_autoposter
424-
* @see topgg::client::get_voters
424+
* @see topgg::client::get_votes
425425
* @since 2.0.0
426426
*/
427-
topgg::async_result<std::vector<voter>> co_get_voters(size_t page = 1);
427+
topgg::async_result<std::vector<vote>> co_get_votes(size_t page = 1);
428428
#endif
429429

430430
/**

include/topgg/models.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ namespace topgg {
4747
class client;
4848

4949
/**
50-
* @brief A Top.gg voter.
50+
* @brief A Top.gg vote.
5151
*
52-
* @see topgg::client::get_voters
52+
* @see topgg::client::get_votes
5353
* @see topgg::client::start_autoposter
5454
* @since 2.0.0
5555
*/
56-
class TOPGG_EXPORT voter {
57-
voter(const dpp::json& j);
56+
class TOPGG_EXPORT vote {
57+
vote(const dpp::json& j);
5858

5959
public:
60-
voter() = delete;
60+
vote() = delete;
6161

6262
/**
6363
* @brief This voter's Discord ID.

src/client.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,29 +167,29 @@ topgg::async_result<std::optional<size_t>> client::co_get_server_count() {
167167
}
168168
#endif
169169

170-
void client::get_voters(size_t page, const topgg::get_voters_completion_event& callback) {
170+
void client::get_votes(size_t page, const topgg::get_votes_completion_event& callback) {
171171
if (page < 1) {
172172
page = 1;
173173
}
174174

175-
basic_request<std::vector<topgg::voter>>("/bots/" + m_id + "/votes?page=" + std::to_string(page), callback, [](const auto& j) {
176-
std::vector<topgg::voter> voters{};
175+
basic_request<std::vector<topgg::vote>>("/bots/" + m_id + "/votes?page=" + std::to_string(page), callback, [](const auto& j) {
176+
std::vector<topgg::vote> votes{};
177177

178178
for (const auto& part: j) {
179-
voters.push_back(topgg::voter{part});
179+
votes.push_back(topgg::vote{part});
180180
}
181181

182-
return voters;
182+
return votes;
183183
});
184184
}
185185

186-
void client::get_voters(const topgg::get_voters_completion_event& callback) {
187-
get_voters(1, callback);
186+
void client::get_votes(const topgg::get_votes_completion_event& callback) {
187+
get_votes(1, callback);
188188
}
189189

190190
#ifdef DPP_CORO
191-
topgg::async_result<std::vector<topgg::voter>> client::co_get_voters(size_t page) {
192-
return topgg::async_result<std::vector<topgg::voter>>{[this, page]<typename C>(C&& cc) { return get_voters(page, std::forward<C>(cc)); }};
191+
topgg::async_result<std::vector<topgg::vote>> client::co_get_votes(size_t page) {
192+
return topgg::async_result<std::vector<topgg::vote>>{[this, page]<typename C>(C&& cc) { return get_votes(page, std::forward<C>(cc)); }};
193193
}
194194
#endif
195195

src/models.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void strptime(const char* s, const char* f, tm* t) {
7272

7373
using topgg::bot;
7474
using topgg::bot_query;
75-
using topgg::voter;
75+
using topgg::vote;
7676

7777
static time_t timestamp_from_id(const dpp::snowflake& id) {
7878
return static_cast<time_t>(((id >> 22) / 1000) + 1420070400);
@@ -185,7 +185,7 @@ dpp::async<std::vector<topgg::bot>> bot_query::co_send() {
185185
}
186186
#endif
187187

188-
voter::voter(const dpp::json& j) {
188+
vote::vote(const dpp::json& j) {
189189
id = _TOPGG_SNOWFLAKE_FROM_JSON(j, id);
190190

191191
_TOPGG_DESERIALIZE(j, username, std::string);

tests/test_api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ int main() {
8888
client.get_server_count(TEST_RESULT_CALLBACK());
8989

9090
ACQUIRE_TEST_THREAD();
91-
std::cout << "get_voters ";
91+
std::cout << "get_votes ";
9292

93-
client.get_voters(TEST_RESULT_CALLBACK());
93+
client.get_votes(TEST_RESULT_CALLBACK());
9494

9595
ACQUIRE_TEST_THREAD();
9696
std::cout << "is_weekend ";

0 commit comments

Comments
 (0)