38 template<>
struct core<discord_core_api::add_guild_member_data> {
39 using value_type = discord_core_api::add_guild_member_data;
40 static constexpr auto parseValue = createValue(
"roles", &value_type::roles,
"access_token", &value_type::accessToken,
"guild_id", &value_type::guildId,
"user_id",
41 &value_type::userId,
"nick", &value_type::nick,
"mute", &value_type::mute,
"deaf", &value_type::deaf);
44 template<>
struct core<discord_core_api::modify_current_guild_member_data> {
45 using value_type = discord_core_api::modify_current_guild_member_data;
46 static constexpr auto parseValue = createValue(
"nick", &value_type::nick);
49 template<>
struct core<discord_core_api::modify_guild_member_data> {
50 using value_type = discord_core_api::modify_guild_member_data;
51 static constexpr auto parseValue = createValue(
"deaf", &value_type::deaf,
"mute", &value_type::mute,
"nick", &value_type::nick,
"roles", &value_type::roleIds,
"channel_id",
52 &value_type::channelId,
"flags", &value_type::flags);
58 modify_guild_member_data::modify_guild_member_data(
const guild_member_data& other) {
62 jsonifierExcludedKeys.emplace(
"roles");
64 this->
deaf = other.deaf;
65 this->
mute = other.mute;
66 this->
nick = other.nick;
67 this->flags =
static_cast<uint32_t
>(other.flags);
73 if (
static_cast<int64_t
>(other.flags) != 0) {
76 setFlagValue(guild_member_flags::Pending, other.pending);
77 setFlagValue(guild_member_flags::Deaf, other.deaf);
78 setFlagValue(guild_member_flags::Mute, other.mute);
79 if (other.permissions.operator std::string_view() !=
"") {
82 if (other.joinedAt !=
"") {
85 if (other.user.id != 0) {
86 user.id = other.user.id;
88 if (other.guildId != 0) {
91 if (other.avatar !=
"") {
94 if (other.roles.size() > 0) {
97 if (other.nick !=
"") {
103 guild_member_cache_data::guild_member_cache_data(
const guild_member_data& other) {
108 if (
static_cast<int64_t
>(other.flags) != 0) {
111 setFlagValue(guild_member_flags::Pending, other.pending);
112 setFlagValue(guild_member_flags::Deaf, other.deaf);
113 setFlagValue(guild_member_flags::Mute, other.mute);
114 if (other.permissions.operator std::string_view() !=
"") {
115 permissionsVal = std::move(other.permissions);
117 if (other.joinedAt !=
"") {
118 joinedAt = std::move(other.joinedAt);
120 if (other.avatar !=
"") {
121 avatar = std::move(other.avatar);
123 if (other.roles.size() > 0) {
124 roles = std::move(other.roles);
126 if (other.nick !=
"") {
127 nick = std::move(other.nick);
129 if (other.user.id != 0) {
130 user.id = other.user.id;
132 if (other.guildId != 0) {
133 guildId = other.guildId;
140 returnData.
permissions = permissionsVal.operator jsonifier::string();
141 returnData.pending = getFlagValue(guild_member_flags::Pending);
142 returnData.deaf = getFlagValue(guild_member_flags::Deaf);
143 returnData.mute = getFlagValue(guild_member_flags::Mute);
144 returnData.joinedAt = joinedAt.operator jsonifier::string();
145 returnData.guildId = guildId;
146 returnData.user.id = user.id;
147 returnData.avatar = avatar;
148 returnData.roles =
roles;
149 returnData.flags = flags;
150 returnData.nick = nick;
154 guild_member_cache_data::guild_member_cache_data(
guild_member_data&& other)
noexcept {
155 *
this = std::move(other);
159 guild_members::doWeCacheGuildMembersBool = configManagerNew->doWeCacheGuildMembers();
160 guild_members::doWeCacheVoiceStatesBool = configManagerNew->doWeCacheVoiceStates();
161 guild_members::httpsClient = client;
165 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Guild_Member };
167 workload.workloadClass = discord_core_internal::https_workload_class::Get;
168 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/members/" + dataPackage.
guildMemberId;
169 workload.callStack =
"guild_members::getGuildMemberAsync()";
170 guild_member_data data{};
172 data.guildId = dataPackage.
guildId;
173 two_id_key key{ data };
174 if (cache.contains(key)) {
177 guild_members::httpsClient->submitWorkloadAndGetResult(std::move(workload), data);
178 if (doWeCacheGuildMembersBool) {
179 insertGuildMember(
static_cast<guild_member_cache_data
>(data));
185 guild_member_cache_data data{};
187 data.guildId = dataPackage.
guildId;
188 two_id_key key{ data };
189 if (cache.contains(key)) {
197 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Guild_Members };
199 workload.workloadClass = discord_core_internal::https_workload_class::Get;
200 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/members";
201 if (dataPackage.
after != 0) {
202 workload.relativePath +=
"?after=" + dataPackage.
after;
203 if (dataPackage.
limit != 0) {
204 workload.relativePath +=
"&limit=" + jsonifier::toString(dataPackage.
limit);
206 }
else if (dataPackage.
limit != 0) {
207 workload.relativePath +=
"?limit=" + jsonifier::toString(dataPackage.
limit);
209 workload.callStack =
"guild_members::listGuildMembersAsync()";
210 jsonifier::vector<guild_member_data> returnData{};
211 guild_members::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
212 co_return returnData;
216 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Get_Search_Guild_Members };
218 workload.workloadClass = discord_core_internal::https_workload_class::Get;
219 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/members/search";
220 if (dataPackage.
query !=
"") {
221 workload.relativePath +=
"?query=" + dataPackage.
query;
222 if (dataPackage.
limit != 0) {
223 workload.relativePath +=
"&limit=" + jsonifier::toString(dataPackage.
limit);
225 }
else if (dataPackage.
limit != 0) {
226 workload.relativePath +=
"?limit=" + jsonifier::toString(dataPackage.
limit);
228 workload.callStack =
"guild_members::searchGuildMembersAsync()";
229 jsonifier::vector<guild_member_data> returnData{};
230 guild_members::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
231 co_return returnData;
235 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Put_Guild_Member };
237 workload.workloadClass = discord_core_internal::https_workload_class::Put;
238 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/members/" + dataPackage.
userId;
239 parser.serializeJson(dataPackage, workload.content);
240 workload.callStack =
"guild_members::addGuildMemberAsync()";
241 guild_member_data returnData{};
242 guild_members::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
243 co_return returnData;
247 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Current_Guild_Member };
249 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
250 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/members/@me";
251 parser.serializeJson(dataPackage, workload.content);
252 workload.callStack =
"guild_members::modifyCurrentGuildMemberAsync()";
253 if (dataPackage.
reason !=
"") {
254 workload.headersToInsert[
"x-audit-log-reason"] = dataPackage.
reason;
256 guild_member_data returnData{};
257 guild_members::httpsClient->submitWorkloadAndGetResult(std::move(workload), returnData);
258 co_return returnData;
262 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Patch_Guild_Member };
264 workload.workloadClass = discord_core_internal::https_workload_class::Patch;
266 dataPackage.jsonifierExcludedKeys.emplace(
"communication_disabled_until");
268 if (dataPackage.
channelId.operator jsonifier::string_base<char>() ==
"0" || dataPackage.
channelId.operator
const uint64_t &() == 0) {
269 dataPackage.jsonifierExcludedKeys.emplace(
"channel_id");
270 dataPackage.jsonifierExcludedKeys.emplace(
"mute");
271 dataPackage.jsonifierExcludedKeys.emplace(
"deaf");
273 if (dataPackage.flags == 0) {
274 dataPackage.jsonifierExcludedKeys.emplace(
"flags");
276 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/members/" + dataPackage.
guildMemberId;
277 parser.serializeJson(dataPackage, workload.content);
278 workload.callStack =
"guild_members::modifyGuildMemberAsync()";
279 if (dataPackage.
reason !=
"") {
280 workload.headersToInsert[
"x-audit-log-reason"] = dataPackage.
reason;
282 guild_member_data data{};
284 data.guildId = dataPackage.
guildId;
285 two_id_key key{ data };
286 if (cache.contains(key)) {
290 guild_members::httpsClient->submitWorkloadAndGetResult(std::move(workload), data);
291 }
catch (
const std::runtime_error& error) {
292 std::cout << error.what() << std::endl;
294 if (doWeCacheGuildMembersBool) {
295 insertGuildMember(
static_cast<guild_member_cache_data
>(data));
301 discord_core_internal::https_workload_data workload{ discord_core_internal::https_workload_type::Delete_Guild_Member };
303 workload.workloadClass = discord_core_internal::https_workload_class::Delete;
304 workload.relativePath =
"/guilds/" + dataPackage.
guildId +
"/members/" + dataPackage.
guildMemberId;
305 workload.callStack =
"guild_members::removeGuildMemberAsync()";
306 if (dataPackage.
reason !=
"") {
307 workload.headersToInsert[
"x-audit-log-reason"] = dataPackage.
reason;
309 guild_members::httpsClient->submitWorkloadAndGetResult(std::move(workload));
315 get_guild_member_data dataNew{ .guildMemberId = dataPackage.
guildMemberId, .guildId = dataPackage.
guildId };
317 modify_guild_member_data dataPackage01{ guildMember };
318 dataPackage01.deaf = guildMember.getFlagValue(guild_member_flags::Deaf);
319 dataPackage01.guildId = guildMember.
guildId;
320 dataPackage01.guildMemberId = guildMember.
user.
id;
321 dataPackage01.mute = guildMember.getFlagValue(guild_member_flags::Mute);
322 for (
auto& value: guildMember.
roles) {
323 dataPackage01.roleIds.emplace_back(value);
325 dataPackage01.nick = guildMember.
nick;
326 dataPackage01.reason = dataPackage.
reason;
327 time_stamp timeStamp{};
331 dataPackage01.communicationDisabledUntil = string;
336 dataPackage01.communicationDisabledUntil = string;
341 dataPackage01.communicationDisabledUntil = string;
346 dataPackage01.communicationDisabledUntil = string;
351 dataPackage01.communicationDisabledUntil = string;
356 dataPackage01.communicationDisabledUntil = string;
361 dataPackage01.communicationDisabledUntil = string;
366 co_return guildMember;
370 if (vsCache.contains(key)) {
377 void guild_members::removeGuildMember(
const two_id_key& key) {
381 void guild_members::removeVoiceState(
const two_id_key& key) {
385 bool guild_members::doWeCacheGuildMembers() {
386 return guild_members::doWeCacheGuildMembersBool;
389 bool guild_members::doWeCacheVoiceStates() {
390 return guild_members::doWeCacheVoiceStatesBool;
396 bool guild_members::doWeCacheGuildMembersBool{};
397 bool guild_members::doWeCacheVoiceStatesBool{};
A co_routine - representing a potentially asynchronous operation/function.
For sending Https requests.
Data structure representing a single guild_member_data.
jsonifier::string nick
Their nick/display name.
icon_hash avatar
This guild_member_data's guild avatar.
time_stamp joinedAt
When they joined the guild.
snowflake guildId
The current guild's id.
user_id_base user
The user id for this guild_member_data.
permissions permissionsVal
Their base-level permissions in the guild.
guild_member_flags flags
Guild_member_data flags.
jsonifier::vector< snowflake > roles
The guild roGuildMemberDatales that they have.
Data structure representing a single guild_member_data.
jsonifier::vector< snowflake > roles
Array of role object ids.
snowflake guildId
The guild that this member belongs to.
permissions_parse permissions
Total permissions of the member in the channel, including overwrites.
user_data user
The user this guild member represents.
jsonifier::string nick
This user's guild nickname.
static co_routine< guild_member_data > modifyCurrentGuildMemberAsync(modify_current_guild_member_data dataPackage)
Modifies the current guild_member_data's properties.
static co_routine< guild_member_data > getGuildMemberAsync(get_guild_member_data dataPackage)
Collects a guild_member from the discord servers.
static co_routine< guild_member_data > addGuildMemberAsync(add_guild_member_data dataPackage)
Adds a guild_member to a chosen guild.
static co_routine< guild_member_data > modifyGuildMemberAsync(modify_guild_member_data dataPackage)
Modifies a guild_member's properties.
static co_routine< guild_member_data > timeoutGuildMemberAsync(timeout_guild_member_data dataPackage)
Times-out a chosen guild_member_data from a chosen guild.
static co_routine< void > removeGuildMemberAsync(remove_guild_member_data dataPackage)
Removes a chosen guild_member_data from a chosen guild.
static guild_member_cache_data getCachedGuildMember(get_guild_member_data dataPackage)
Collects a guild_member from the library's cache.
static co_routine< jsonifier::vector< guild_member_data > > listGuildMembersAsync(list_guild_members_data dataPackage)
Lists all of the guild_members of a chosen guild.
static voice_state_data_light getVoiceStateData(const two_id_key &voiceState)
Collect a given guild_member's voice state data.
static co_routine< jsonifier::vector< guild_member_data > > searchGuildMembersAsync(search_guild_members_data dataPackage)
Searches for a list of guild_members of a chosen guild.
A template class representing an object cache.
An interface class for the role_data related discord endpoints.
uint64_t id
The snowflake id.
snowflake id
The user's id.
@ Minute
1 minute timeout.
@ None
None - erase timeout.
@ Ten_Minutes
10 minute timeout.
@ Five_Minutes
5 minute timeout.
DCA_INLINE auto newThreadAwaitable()
An awaitable that can be used to launch the co_routine onto a new thread - as well as return the hand...
@ long_date_time
"Tuesday, 20 April 2021 16:20" - Long Date/Time
The main namespace for the forward-facing interfaces.
For adding a new guild_member_data to a chosen guild.
snowflake userId
The user_data id of the user you wish to add.
snowflake guildId
The guild to add the new guild_member_data to.
For getting a guild_member, from the library's cache or discord server.
snowflake guildMemberId
The user id of the desired guild_member_data.
snowflake guildId
The id of the guild from which you would like to acquire a member.
For listing the guild_members of a chosen guild.
snowflake after
The highest user id in the previous page.
int32_t limit
Max number of members to return (1 - 1000).
snowflake guildId
Guild from which to list the guild_members.
For modifying the current guild_member_data's values.
jsonifier::string reason
A reason for modifying the current user's values.
snowflake guildId
The guild within which to modify the current user's values.
For modifying a guild_member's values.
snowflake guildId
The id of the guild for which you would like to modify a member.
jsonifier::string communicationDisabledUntil
When the user's timeout will expire and the user will be able to communicate in the guild again.
jsonifier::vector< snowflake > roleIds
A collection of role_data id's to be applied to them.
bool deaf
Whether or not to deafen them, in voice.
bool mute
Whether or not to mute them in voice.
snowflake channelId
The current voice channel_data, if applicaple.
jsonifier::string reason
Reason for modifying this guild_member_data.
jsonifier::string nick
Their new display/nick name.
snowflake guildMemberId
The user id of the desired guild memeber.
For removing a guild_member from a chosen guild.
snowflake guildMemberId
snowflake of the chosen guild_member_data to kick.
snowflake guildId
Guild from which to kick the chosen guild_member_data.
jsonifier::string reason
Reason for kicking the guild_member_data.
For searching for one or more guild_members within a chosen guild.
int32_t limit
Max number of members to return (1 - 1000).
snowflake guildId
Guild within which to search for the guild_members.
jsonifier::string query
Query jsonifier::string to match username(s) and nickname(s) against.
For timing out a guild_member.
jsonifier::string reason
Reason for timing them out.
snowflake guildMemberId
The id of the guild_member_data to be timed-out.
snowflake guildId
The id of the guild from which you would like to acquire a member.
timeout_durations numOfMinutesToTimeoutFor
The number of minutes to time-out the guild_member_data for.
snowflake channelId
The channel_data id this user_data is connected to.