Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 6515eac

Browse files
committed
Added option to retrieve bulk members
1 parent 99519d0 commit 6515eac

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

include/aegis/core.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,23 +501,27 @@ class core
501501
}
502502

503503
std::unordered_map<snowflake, std::unique_ptr<channel>> channels;
504-
std::unordered_map<snowflake, std::unique_ptr<channel>> stale_channels;
504+
std::unordered_map<snowflake, std::unique_ptr<channel>> stale_channels; //<\todo do something with stales - clear them?
505505
std::unordered_map<snowflake, std::unique_ptr<guild>> guilds;
506-
std::unordered_map<snowflake, std::unique_ptr<guild>> stale_guilds;
506+
std::unordered_map<snowflake, std::unique_ptr<guild>> stale_guilds; //<\todo do something with stales - clear them?
507507
#if !defined(AEGIS_DISABLE_ALL_CACHE)
508508
std::unordered_map<snowflake, std::unique_ptr<user>> users;
509-
std::unordered_map<snowflake, std::unique_ptr<user>> stale_users;
509+
std::unordered_map<snowflake, std::unique_ptr<user>> stale_users; //<\todo do something with stales - clear them?
510510
#endif
511511
std::map<std::string, uint64_t> message_count;
512512

513513
std::string self_presence;
514514
uint32_t force_shard_count = 0;
515-
uint32_t shard_max_count = 0;
515+
uint32_t shard_max_count = 0; //<\deprecated moving into private
516516
std::string mention;
517517
bool wsdbg = false;
518518
std::unique_ptr<asio::io_context::strand> ws_open_strand;
519519
std::shared_ptr<spdlog::logger> log;
520520

521+
void bulk_members_on_connect(bool param) { bulk_members_on_connect_ = param; }
522+
bool bulk_members_on_connect() { return bulk_members_on_connect_; }
523+
int64_t shard_count() { return shard_max_count; }
524+
521525
#if defined(AEGIS_PROFILING)
522526
using message_end_t = std::function<void(std::chrono::steady_clock::time_point, const std::string&)>;
523527
using rest_end_t = std::function<void(std::chrono::steady_clock::time_point, uint16_t)>;
@@ -535,6 +539,7 @@ class core
535539
websocket_event_t websocket_event;
536540
#endif
537541

542+
#pragma region event handlers
538543
using typing_start_t = std::function<void(gateway::events::typing_start obj)>;
539544
using message_create_t = std::function<void(gateway::events::message_create obj)>;
540545
using message_update_t = std::function<void(gateway::events::message_update obj)>;
@@ -718,6 +723,7 @@ class core
718723
{
719724
_shard_mgr->i_shard_connect = cb;
720725
}
726+
#pragma endregion
721727

722728
/// Send a websocket message to a single shard
723729
/**
@@ -1057,6 +1063,8 @@ class core
10571063

10581064
std::chrono::steady_clock::time_point starttime;
10591065

1066+
bool bulk_members_on_connect_ = true; //<\todo will eventually default to false
1067+
10601068
snowflake user_id;
10611069
int16_t discriminator = 0;
10621070
std::string username;

include/aegis/impl/core.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,12 +1349,15 @@ AEGIS_DECL void core::ws_guild_create(const json & result, shards::shard * _shar
13491349

13501350
_guild->_load(result["d"], _shard);
13511351

1352-
json chunk;
1353-
chunk["d"]["guild_id"] = std::to_string(guild_id);
1354-
chunk["d"]["query"] = "";
1355-
chunk["d"]["limit"] = 0;
1356-
chunk["op"] = 8;
1357-
_shard->send(chunk.dump());
1352+
if (bulk_members_on_connect())
1353+
{
1354+
json chunk;
1355+
chunk["d"]["guild_id"] = std::to_string(guild_id);
1356+
chunk["d"]["query"] = "";
1357+
chunk["d"]["limit"] = 0;
1358+
chunk["op"] = 8;
1359+
_shard->send(chunk.dump());
1360+
}
13581361

13591362
gateway::events::guild_create obj{ *_shard };
13601363
obj.guild = result["d"];

0 commit comments

Comments
 (0)