DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
EventManager.cpp
Go to the documentation of this file.
1/*
2 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3
4 Copyright 2021, 2022 Chris M. (RealTimeChris)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
20*/
21/// EventManager.hpp - Header for the event manager class.
22/// Jun 7, 2021
23/// https://discordcoreapi.com
24/// \file EventManager.cpp
25
30
31namespace DiscordCoreAPI {
32
33 OnInputEventCreationData::OnInputEventCreationData(DiscordCoreInternal::WebSocketMessage& message, simdjson::ondemand::value data) {
34 this->inputEventData = message.processJsonMessage<InputEventData>(data, "d");
35 }
36
37 OnApplicationCommandPermissionsUpdateData::OnApplicationCommandPermissionsUpdateData(DiscordCoreInternal::WebSocketMessage& message,
38 simdjson::ondemand::value data) {
39 this->permissionData = message.processJsonMessage<GuildApplicationCommandPermissionsData>(data, "d");
40 }
41
42 OnAutoModerationRuleCreationData::OnAutoModerationRuleCreationData(DiscordCoreInternal::WebSocketMessage& message,
43 simdjson::ondemand::value data) {
44 this->theRule = message.processJsonMessage<AutoModerationRule>(data, "d");
45 }
46
47 OnAutoModerationRuleUpdateData::OnAutoModerationRuleUpdateData(DiscordCoreInternal::WebSocketMessage& message, simdjson::ondemand::value data) {
48 this->theRule = message.processJsonMessage<AutoModerationRule>(data, "d");
49 }
50
51 OnAutoModerationRuleDeletionData::OnAutoModerationRuleDeletionData(DiscordCoreInternal::WebSocketMessage& message,
52 simdjson::ondemand::value data) {
53 this->theRule = message.processJsonMessage<AutoModerationRule>(data, "d");
54 }
55
56 OnAutoModerationActionExecutionData::OnAutoModerationActionExecutionData(DiscordCoreInternal::WebSocketMessage& message,
57 simdjson::ondemand::value data) {
58 this->data = message.processJsonMessage<AutoModerationActionExecutionEventData>(data, "d");
59 }
60
61 OnChannelCreationData::OnChannelCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
62 this->channel = std::make_unique<ChannelData>(data.processJsonMessage<ChannelData>(dataReal, "d"));
63 if (Channels::doWeCacheChannels()) {
64 GuildData guild{};
65 guild.id = this->channel->guildId;
66 if (Guilds::getCache().contains(guild)) {
67 Guilds::getCache()[guild].channels.emplace_back(this->channel->id);
68 }
69 if (Channels::doWeCacheChannels()) {
70 Channels::insertChannel(*this->channel);
71 }
72 }
73 }
74
75 OnChannelCreationData& OnChannelCreationData::operator=(const OnChannelCreationData& other) {
76 *this->channel = *other.channel;
77 return *this;
78 }
79
80 OnChannelCreationData::OnChannelCreationData(const OnChannelCreationData& other) {
81 *this = other;
82 }
83
84 OnChannelUpdateData::OnChannelUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
85 this->channel = std::make_unique<ChannelData>(data.processJsonMessage<ChannelData>(dataReal, "d"));
86 if (Channels::doWeCacheChannels()) {
87 Channels::insertChannel(*this->channel);
88 }
89 }
90
91 OnChannelUpdateData& OnChannelUpdateData::operator=(const OnChannelUpdateData& other) {
92 *this->channel = *other.channel;
93 return *this;
94 }
95
96 OnChannelUpdateData::OnChannelUpdateData(const OnChannelUpdateData& other) {
97 *this = other;
98 }
99
100 OnChannelDeletionData::OnChannelDeletionData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
101 this->channel = std::make_unique<ChannelData>(data.processJsonMessage<ChannelData>(dataReal, "d"));
102 if (Channels::doWeCacheChannels()) {
103 GuildData guild{};
104 guild.id = this->channel->guildId;
105 if (Guilds::getCache().contains(guild)) {
106 for (uint64_t x = 0; x < Guilds::getCache()[guild].channels.size(); ++x) {
107 if (Guilds::getCache()[guild].channels[x] == this->channel->id) {
108 Guilds::getCache()[guild].channels.erase(Guilds::getCache()[guild].channels.begin() + x);
109 }
110 }
111 }
112 if (Channels::doWeCacheChannels()) {
113 Channels::removeChannel(this->channel->id);
114 }
115 }
116 }
117
118 OnChannelDeletionData& OnChannelDeletionData::operator=(const OnChannelDeletionData& other) {
119 *this->channel = *other.channel;
120 return *this;
121 }
122
123 OnChannelDeletionData::OnChannelDeletionData(const OnChannelDeletionData& other) {
124 *this = other;
125 }
126
127 OnChannelPinsUpdateData::OnChannelPinsUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
128 this->dataPackage = data.processJsonMessage<ChannelPinsUpdateEventData>(dataReal, "d");
129 }
130
131 OnThreadCreationData::OnThreadCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
132 this->thread = data.processJsonMessage<Thread>(dataReal, "d");
133 GuildData guild{};
134 guild.id = this->thread.guildId;
135 if (Guilds::getCache().contains(guild)) {
136 Guilds::getCache()[guild].threads.emplace_back(this->thread.id);
137 }
138 }
139
140 OnThreadUpdateData::OnThreadUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
141 this->thread = data.processJsonMessage<Thread>(dataReal, "d");
142 }
143
144 OnThreadDeletionData::OnThreadDeletionData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
145 this->thread = data.processJsonMessage<Thread>(dataReal, "d");
146 GuildData guild{};
147 guild.id = this->thread.guildId;
148 if (Guilds::getCache().contains(guild)) {
149 for (uint64_t x = 0; x < Guilds::getCache()[guild].threads.size(); ++x) {
150 if (Guilds::getCache()[guild].threads[x] == this->thread.id) {
151 Guilds::getCache()[guild].threads.erase(Guilds::getCache()[guild].threads.begin() + x);
152 }
153 }
154 }
155 }
156
157 OnThreadListSyncData::OnThreadListSyncData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
158 this->threadListSyncData = data.processJsonMessage<ThreadListSyncData>(dataReal, "d");
159 }
160
161 OnThreadMemberUpdateData::OnThreadMemberUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
162 this->threadMember = data.processJsonMessage<ThreadMemberData>(dataReal, "d");
163 }
164
165 OnThreadMembersUpdateData::OnThreadMembersUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
166 this->threadMembersUpdateData = data.processJsonMessage<ThreadMembersUpdateData>(dataReal, "d");
167 }
168
169 OnGuildCreationData::OnGuildCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
170 DiscordCoreClient* client) {
171 this->guild = std::make_unique<GuildData>(data.processJsonMessage<GuildData>(dataReal, "d"));
172 this->guild->discordCoreClient = client;
173 if (Guilds::doWeCacheGuilds()) {
174 if (Guilds::doWeCacheGuilds()) {
175 Guilds::insertGuild(*this->guild);
176 }
177 }
178 }
179
180 OnGuildCreationData& OnGuildCreationData::operator=(const OnGuildCreationData& other) {
181 *this->guild = *other.guild;
182 return *this;
183 }
184
185 OnGuildCreationData::OnGuildCreationData(const OnGuildCreationData& other) {
186 *this = other;
187 }
188
189 OnGuildUpdateData::OnGuildUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
190 DiscordCoreClient* clientNew) {
191 this->guild = std::make_unique<GuildData>(data.processJsonMessage<GuildData>(dataReal, "d"));
192 this->guild->discordCoreClient = clientNew;
193 if (Guilds::doWeCacheGuilds()) {
194 Guilds::insertGuild(*this->guild);
195 }
196 }
197
198 OnGuildUpdateData& OnGuildUpdateData::operator=(const OnGuildUpdateData& other) {
199 *this->guild = *other.guild;
200 return *this;
201 }
202
203 OnGuildUpdateData::OnGuildUpdateData(const OnGuildUpdateData& other) {
204 *this = other;
205 }
206
207 OnGuildDeletionData::OnGuildDeletionData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
208 DiscordCoreClient* clientNew) {
209 this->guild = std::make_unique<GuildData>(data.processJsonMessage<GuildData>(dataReal, "d"));
210 if (Guilds::doWeCacheGuilds()) {
211 Guilds::removeGuild(this->guild->id);
212 }
213 for (auto& valueNew: this->guild->members) {
214 GuildMemberData guildMember = GuildMembers::getCachedGuildMember({ .guildMemberId = valueNew, .guildId = this->guild->id });
215 GuildMembers::removeGuildMember(guildMember);
216 }
217 for (auto& valueNew: this->guild->channels) {
218 Channels::removeChannel(valueNew);
219 }
220 for (auto& valueNew: this->guild->roles) {
221 Roles::removeRole(valueNew);
222 }
223 }
224
225 OnGuildDeletionData& OnGuildDeletionData::operator=(const OnGuildDeletionData& other) {
226 *this->guild = *other.guild;
227 return *this;
228 }
229
230 OnGuildDeletionData::OnGuildDeletionData(const OnGuildDeletionData& other) {
231 *this = other;
232 }
233
234 OnGuildBanAddData::OnGuildBanAddData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
235 this->guildId = getId(dataReal["d"], "guild_id");
236 this->user = data.processJsonMessage<UserData>(dataReal["d"], "user");
237 }
238
239 OnGuildBanRemoveData::OnGuildBanRemoveData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
240 this->guildId = getId(dataReal["d"], "guild_id");
241 this->user = data.processJsonMessage<UserData>(dataReal["d"], "user");
242 }
243
244 OnGuildEmojisUpdateData::OnGuildEmojisUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
245 this->updateData = data.processJsonMessage<GuildEmojisUpdateEventData>(dataReal, "d");
246 GuildData guild{};
247 guild.id = this->updateData.guildId;
248 if (Guilds::getCache().contains(guild)) {
249 Guilds::getCache()[guild].emoji.clear();
250 for (auto& valueNew: this->updateData.emojis) {
251 Guilds::getCache()[guild].emoji.emplace_back(valueNew.id);
252 }
253 }
254 }
255
256 OnGuildStickersUpdateData::OnGuildStickersUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
257 this->updateData = data.processJsonMessage<GuildStickersUpdateEventData>(dataReal, "d");
258 GuildData guild{};
259 guild.id = this->updateData.guildId;
260 if (Guilds::getCache().contains(guild)) {
261 Guilds::getCache()[guild].stickers.clear();
262 for (auto& valueNew: this->updateData.stickers) {
263 Guilds::getCache()[guild].stickers.emplace_back(valueNew.id);
264 }
265 }
266 }
267
268 OnGuildIntegrationsUpdateData::OnGuildIntegrationsUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
269 this->guildId = getId(dataReal["d"], "guild_id");
270 }
271
272 OnGuildMemberAddData::OnGuildMemberAddData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
273 DiscordCoreClient* client) {
274 this->guildMember = std::make_unique<GuildMemberData>(data.processJsonMessage<GuildMemberData>(dataReal, "d"));
275 this->discordCoreClient = client;
276 if (GuildMembers::doWeCacheGuildMembers()) {
277 GuildMembers::insertGuildMember(*this->guildMember);
278 GuildData guild{};
279 guild.id = guildMember->guildId;
280 if (Guilds::getCache().contains(guild)) {
281 ++Guilds::getCache()[guild].memberCount;
282 }
283 }
284 }
285
286 OnGuildMemberAddData& OnGuildMemberAddData::operator=(const OnGuildMemberAddData& other) {
287 this->discordCoreClient = other.discordCoreClient;
288 *this->guildMember = *other.guildMember;
289 return *this;
290 }
291
292 OnGuildMemberAddData::OnGuildMemberAddData(const OnGuildMemberAddData& other) {
293 *this = other;
294 }
295
296 OnGuildMemberRemoveData::OnGuildMemberRemoveData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
297 DiscordCoreClient* client) {
298 this->discordCoreClient = client;
299 this->guildId = getId(dataReal["d"], "guild_id");
300 this->user = std::make_unique<UserData>(data.processJsonMessage<UserData>(dataReal["d"], "user"));
301 GuildMember guildMember = GuildMembers::getCachedGuildMember({ .guildMemberId = this->user->id, .guildId = this->guildId });
302 if (GuildMembers::doWeCacheGuildMembers()) {
303 GuildData guild{};
304 guild.id = this->guildId;
305 GuildMembers::removeGuildMember(guildMember);
306 if (Guilds::getCache().contains(guild)) {
307 for (uint64_t x = 0; x < Guilds::getCache()[guild].members.size(); ++x) {
308 if (Guilds::getCache()[guild].members[x] == this->user->id) {
309 --Guilds::getCache()[guild].memberCount;
310 Guilds::getCache()[guild].members.erase(Guilds::getCache()[guild].members.begin() + x);
311 }
312 }
313 }
314 }
315 }
316
317 OnGuildMemberRemoveData& OnGuildMemberRemoveData::operator=(const OnGuildMemberRemoveData& other) {
318 this->discordCoreClient = other.discordCoreClient;
319 this->guildId = other.guildId;
320 *this->user = *other.user;
321 return *this;
322 }
323
324 OnGuildMemberRemoveData::OnGuildMemberRemoveData(const OnGuildMemberRemoveData& other) {
325 *this = other;
326 }
327
328 OnGuildMemberUpdateData::OnGuildMemberUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
329 DiscordCoreClient* client) {
330 this->guildMember = std::make_unique<GuildMemberData>(data.processJsonMessage<GuildMemberData>(dataReal, "d"));
331 if (GuildMembers::doWeCacheGuildMembers()) {
332 GuildMembers::insertGuildMember(*this->guildMember);
333 }
334 }
335
336 OnGuildMemberUpdateData& OnGuildMemberUpdateData::operator=(const OnGuildMemberUpdateData& other) {
337 *this->guildMember = *other.guildMember;
338 return *this;
339 }
340
341 OnGuildMemberUpdateData::OnGuildMemberUpdateData(const OnGuildMemberUpdateData& other) {
342 *this = other;
343 }
344
345 OnGuildMembersChunkData::OnGuildMembersChunkData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
346 this->chunkEventData = data.processJsonMessage<GuildMembersChunkEventData>(dataReal, "d");
347 }
348
349 OnRoleCreationData::OnRoleCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
350 this->guildId = getId(dataReal["d"], "guild_id");
351 this->role = std::make_unique<RoleData>(data.processJsonMessage<RoleData>(dataReal["d"], "role"));
352 GuildData guild{};
353 guild.id = guildId;
354 if (Guilds::getCache().contains(guild)) {
355 Guilds::getCache()[guild].roles.emplace_back(this->role->id);
356 }
357 if (Roles::doWeCacheRoles()) {
358 Roles::insertRole(*this->role);
359 }
360 }
361
362 OnRoleCreationData& OnRoleCreationData::operator=(const OnRoleCreationData& other) {
363 this->guildId = other.guildId;
364 *this->role = *other.role;
365 return *this;
366 }
367
368 OnRoleCreationData::OnRoleCreationData(const OnRoleCreationData& other) {
369 *this = other;
370 }
371
372 OnRoleUpdateData::OnRoleUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
373 this->guildId = getId(dataReal["d"], "guild_id");
374 this->role = std::make_unique<RoleData>(data.processJsonMessage<RoleData>(dataReal["d"], "role"));
375 if (Roles::doWeCacheRoles()) {
376 Roles::insertRole(*this->role);
377 }
378 }
379
380 OnRoleUpdateData& OnRoleUpdateData::operator=(const OnRoleUpdateData& other) {
381 this->guildId = other.guildId;
382 *this->role = *other.role;
383 return *this;
384 }
385
386 OnRoleUpdateData::OnRoleUpdateData(const OnRoleUpdateData& other) {
387 *this = other;
388 }
389
390 OnRoleDeletionData::OnRoleDeletionData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
391 this->role->id = getId(dataReal["d"], "role_id");
392 this->guildId = getId(dataReal["d"], "guild_id");
393 this->role = std::make_unique<RoleData>(Roles::getCachedRole({ .guildId = this->guildId, .roleId = this->role->id }));
394 GuildData guild{};
395 guild.id = this->guildId;
396 if (Roles::doWeCacheRoles()) {
397 Roles::removeRole(this->role->id);
398 if (Guilds::getCache().contains(guild)) {
399 for (uint64_t x = 0; x < Guilds::getCache()[guild].roles.size(); ++x) {
400 if (Guilds::getCache()[guild].roles[x] == this->role->id) {
401 Guilds::getCache()[guild].roles.erase(Guilds::getCache()[guild].roles.begin() + x);
402 }
403 }
404 }
405 }
406 }
407
408 OnRoleDeletionData& OnRoleDeletionData::operator=(const OnRoleDeletionData& other) {
409 this->guildId = other.guildId;
410 *this->role = *other.role;
411 return *this;
412 }
413
414 OnRoleDeletionData::OnRoleDeletionData(const OnRoleDeletionData& other) {
415 *this = other;
416 }
417
418 OnUserUpdateData& OnUserUpdateData::operator=(const OnUserUpdateData& other) {
419 *this->user = *other.user;
420 return *this;
421 }
422
423 OnUserUpdateData::OnUserUpdateData(const OnUserUpdateData& other) {
424 *this = other;
425 }
426
427 OnVoiceServerUpdateData::OnVoiceServerUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
428 DiscordCoreInternal::WebSocketClient* sslShard) {
429 this->endpoint = getString(dataReal["d"], "endpoint");
430 this->guildId = getId(dataReal["d"], "guild_id");
431 this->token = getString(dataReal["d"], "token");
432 sslShard->voiceConnectionData.endPoint = this->endpoint;
433 sslShard->voiceConnectionData.token = this->token;
434 if (sslShard->areWeCollectingData && !sslShard->serverUpdateCollected && !sslShard->stateUpdateCollected) {
435 sslShard->voiceConnectionData = DiscordCoreInternal::VoiceConnectionData{};
436 sslShard->serverUpdateCollected = true;
437 } else if (sslShard->areWeCollectingData && !sslShard->serverUpdateCollected) {
438 if (sslShard->voiceConnectionDataBuffersMap.contains(this->guildId.operator size_t())) {
439 sslShard->voiceConnectionDataBuffersMap[this->guildId.operator size_t()]->send(sslShard->voiceConnectionData);
440 }
441 sslShard->serverUpdateCollected = false;
442 sslShard->stateUpdateCollected = false;
443 sslShard->areWeCollectingData = false;
444 }
445 };
446
447 OnGuildScheduledEventCreationData::OnGuildScheduledEventCreationData(DiscordCoreInternal::WebSocketMessage& data,
448 simdjson::ondemand::value dataReal) {
449 this->guildScheduledEvent = data.processJsonMessage<GuildScheduledEventData>(dataReal, "d");
450 GuildData guild{};
451 guild.id = this->guildScheduledEvent.guildId;
452 if (Guilds::getCache().contains(guild)) {
453 Guilds::getCache()[guild].guildScheduledEvents.emplace_back(this->guildScheduledEvent.id);
454 }
455 }
456
457 OnGuildScheduledEventUpdateData::OnGuildScheduledEventUpdateData(DiscordCoreInternal::WebSocketMessage& data,
458 simdjson::ondemand::value dataReal) {
459 this->guildScheduledEvent = data.processJsonMessage<GuildScheduledEventData>(dataReal, "d");
460 }
461
462 OnGuildScheduledEventDeletionData::OnGuildScheduledEventDeletionData(DiscordCoreInternal::WebSocketMessage& data,
463 simdjson::ondemand::value dataReal) {
464 this->guildScheduledEvent = data.processJsonMessage<GuildScheduledEventData>(dataReal, "d");
465 GuildData guild{};
466 guild.id = this->guildScheduledEvent.guildId;
467 if (Guilds::getCache().contains(guild)) {
468 for (uint64_t x = 0; x < Guilds::getCache()[guild].guildScheduledEvents.size(); ++x) {
469 if (Guilds::getCache()[guild].guildScheduledEvents[x] == this->guildScheduledEvent.id) {
470 Guilds::getCache()[guild].guildScheduledEvents.erase(Guilds::getCache()[guild].guildScheduledEvents.begin() + x);
471 }
472 }
473 }
474 }
475
476 OnGuildScheduledEventUserAddData::OnGuildScheduledEventUserAddData(DiscordCoreInternal::WebSocketMessage& data,
477 simdjson::ondemand::value dataReal) {
478 this->guildScheduledEventId = getId(dataReal["d"], "guild_scheduled_event_id");
479 this->guildId = getId(dataReal["d"], "guild_id");
480 this->userId = getId(dataReal["d"], "user_id");
481 }
482
483 OnGuildScheduledEventUserRemoveData::OnGuildScheduledEventUserRemoveData(DiscordCoreInternal::WebSocketMessage& data,
484 simdjson::ondemand::value dataReal) {
485 this->guildScheduledEventId = getId(dataReal["d"], "guild_scheduled_event_id");
486 this->guildId = getId(dataReal["d"], "guild_id");
487 this->userId = getId(dataReal["d"], "user_id");
488 }
489
490 OnIntegrationCreationData::OnIntegrationCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
491 this->guildId = getId(dataReal["d"], "guild_id");
492 simdjson::ondemand::value objectNew{};
493 if (dataReal["d"]["integration"].get(objectNew) == simdjson::error_code::SUCCESS) {
494 this->integrationData = IntegrationData{ objectNew };
495 }
496 }
497
498 OnIntegrationUpdateData::OnIntegrationUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
499 this->guildId = getId(dataReal["d"], "guild_id");
500 simdjson::ondemand::value objectNew{};
501 if (dataReal["d"]["integration"].get(objectNew) == simdjson::error_code::SUCCESS) {
502 this->integrationData = IntegrationData{ objectNew };
503 }
504 }
505
506 OnIntegrationDeletionData::OnIntegrationDeletionData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
507 this->applicationId = getId(dataReal["d"], "application_id");
508 this->guildId = getId(dataReal["d"], "guild_id");
509 this->id = getId(dataReal["d"], "id");
510 }
511
512 OnInteractionCreationData::OnInteractionCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
513 DiscordCoreClient* clientPtr) {
514 this->interactionData = InteractionData{ data.processJsonMessage<InteractionData>(dataReal, "d") };
515 std::unique_ptr<InputEventData> eventData{ std::make_unique<InputEventData>(interactionData) };
516 switch (interactionData.type) {
518 eventData->responseType = InputEventResponseType::Unset;
519 *eventData->interactionData = this->interactionData;
520 std::unique_ptr<CommandData> commandData{ std::make_unique<CommandData>(*eventData) };
521 commandData->discordCoreClient = eventData->getGuildData().discordCoreClient;
522 clientPtr->getCommandController().checkForAndRunCommand(*commandData);
523 std::unique_ptr<OnInputEventCreationData> eventCreationData{ std::make_unique<OnInputEventCreationData>(data, dataReal) };
524 eventCreationData->inputEventData = *eventData;
525 break;
526 }
530 eventData->responseType = InputEventResponseType::Unset;
531 *eventData->interactionData = this->interactionData;
532 if (ButtonCollector::buttonInteractionBuffersMap.contains(eventData->getChannelData().id + eventData->getMessageData().id)) {
533 ButtonCollector::buttonInteractionBuffersMap[eventData->getChannelData().id + eventData->getMessageData().id]->send(
535 }
536 ButtonCollector::buttonInteractionEventsMap.operator()(*eventData->interactionData);
537 break;
538 }
544 eventData->responseType = InputEventResponseType::Unset;
545 *eventData->interactionData = this->interactionData;
546 if (SelectMenuCollector::selectMenuInteractionBuffersMap.contains(
547 eventData->getChannelData().id + eventData->getMessageData().id)) {
548 SelectMenuCollector::selectMenuInteractionBuffersMap[eventData->getChannelData().id + eventData->getMessageData().id]
549 ->send(interactionData);
550 }
551 SelectMenuCollector::selectMenuInteractionEventsMap.operator()(*eventData->interactionData);
552 break;
553 }
554 }
555 break;
556 }
558 eventData->responseType = InputEventResponseType::Unset;
559 *eventData->interactionData = this->interactionData;
560 std::unique_ptr<OnInputEventCreationData> eventCreationData{ std::make_unique<OnInputEventCreationData>(data, dataReal) };
561 eventCreationData->inputEventData = *eventData;
562 if (ModalCollector::modalInteractionBuffersMap.contains(eventData->getChannelData().id)) {
563 ModalCollector::modalInteractionBuffersMap[eventData->getChannelData().id]->send(eventData->getInteractionData());
564 ModalCollector::modalInteractionEventsMap.operator()(*eventData->interactionData);
565 }
566 break;
567 }
569 eventData->responseType = InputEventResponseType::Unset;
570 *eventData->interactionData = this->interactionData;
571 std::unique_ptr<OnAutoCompleteEntryData> autocompleteEntryData{ std::make_unique<OnAutoCompleteEntryData>(data, dataReal) };
572 autocompleteEntryData->inputEvent = *eventData;
573 clientPtr->getEventManager().onAutoCompleteEntryEvent(*autocompleteEntryData);
574 break;
575 }
576 }
577 }
578
579 OnInviteCreationData::OnInviteCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
580 this->invite = data.processJsonMessage<InviteData>(dataReal, "d");
581 }
582
583 OnInviteDeletionData::OnInviteDeletionData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
584 this->channelId = getId(dataReal["d"], "channel_id");
585 this->guildId = getId(dataReal["d"], "guild_id");
586 this->code = getId(dataReal["d"], "code");
587 }
588
589 OnMessageCreationData::OnMessageCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
590 this->message = data.processJsonMessage<Message>(dataReal, "d");
591 for (auto& [key, dValue]: MessageCollector::objectsBuffersMap) {
592 dValue->send(this->message);
593 }
594 }
595
596 OnMessageUpdateData::OnMessageUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
597 this->messageNew = data.processJsonMessage<Message>(dataReal, "d");
598 for (auto& [key, dValue]: MessageCollector::objectsBuffersMap) {
599 dValue->send(this->messageNew);
600 }
601 }
602
603 OnMessageDeletionData::OnMessageDeletionData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
604 this->channelId = getId(dataReal["d"], "channel_id");
605 this->guildId = getId(dataReal["d"], "guild_id");
606 this->messageId = getId(dataReal["d"], "id");
607 }
608
609 OnMessageDeleteBulkData::OnMessageDeleteBulkData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
610 this->channelId = getId(dataReal["d"], "channel_id");
611 this->guildId = getId(dataReal["d"], "guild_id");
612 simdjson::ondemand::array arrayValue{};
613 if (dataReal["d"]["ids"].get(arrayValue) == simdjson::error_code::SUCCESS) {
614 for (auto dValue: arrayValue) {
615 this->ids.emplace_back(strtoull(dValue.get_string().take_value()));
616 }
617 }
618 }
619
620 OnReactionAddData::OnReactionAddData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
621 this->reaction = data.processJsonMessage<Reaction>(dataReal, "d");
622 }
623
624 OnReactionRemoveData::OnReactionRemoveData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
625 this->reactionRemoveData = data.processJsonMessage<ReactionRemoveData>(dataReal, "d");
626 }
627
628 OnReactionRemoveAllData::OnReactionRemoveAllData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
629 this->messageId = getId(dataReal["d"], "message_id");
630 this->channelId = getId(dataReal["d"], "channel_id");
631 this->guildId = getId(dataReal["d"], "guild_id");
632 }
633
634 OnReactionRemoveEmojiData::OnReactionRemoveEmojiData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
635 this->channelId = getId(dataReal["d"], "channel_id");
636 this->messageId = getId(dataReal["d"], "message_id");
637 this->guildId = getId(dataReal["d"], "guild_id");
638 simdjson::ondemand::value objectNew{};
639 if (dataReal["d"]["emoji"].get(objectNew) == simdjson::error_code::SUCCESS) {
640 this->emoji = EmojiData{ objectNew };
641 }
642 }
643
644 OnPresenceUpdateData::OnPresenceUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
645 this->presenceData = data.processJsonMessage<PresenceUpdateData>(dataReal, "d");
646 }
647
648 OnStageInstanceCreationData::OnStageInstanceCreationData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
649 this->stageInstance = data.processJsonMessage<StageInstance>(dataReal, "d");
650 GuildData guild{};
651 guild.id = this->stageInstance.guildId;
652 if (Guilds::getCache().contains(guild)) {
653 Guilds::getCache()[guild].stageInstances.emplace_back(this->stageInstance.id);
654 }
655 }
656
657 OnStageInstanceUpdateData::OnStageInstanceUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
658 this->stageInstance = data.processJsonMessage<StageInstance>(dataReal, "d");
659 }
660
661 OnStageInstanceDeletionData::OnStageInstanceDeletionData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
662 this->stageInstance = data.processJsonMessage<StageInstance>(dataReal, "d");
663 GuildData guild{};
664 guild.id = this->stageInstance.guildId;
665 if (Guilds::getCache().contains(guild)) {
666 for (uint64_t x = 0; x < Guilds::getCache()[guild].stageInstances.size(); ++x) {
667 if (Guilds::getCache()[guild].stageInstances[x] == this->stageInstance.id) {
668 Guilds::getCache()[guild].stageInstances.erase(Guilds::getCache()[guild].stageInstances.begin() + x);
669 }
670 }
671 }
672 }
673
674 OnTypingStartData::OnTypingStartData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
675 this->typingStartData = data.processJsonMessage<TypingStartData>(dataReal, "d");
676 }
677
678 OnUserUpdateData::OnUserUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
679 this->user = std::make_unique<UserData>(data.processJsonMessage<UserData>(dataReal, "d"));
680 if (Users::doWeCacheUsers()) {
681 Users::insertUser(*user);
682 }
683 }
684
685 OnVoiceStateUpdateData::OnVoiceStateUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal,
686 DiscordCoreInternal::WebSocketClient* sslShard) {
687 this->voiceStateData = data.processJsonMessage<VoiceStateData>(dataReal, "d");
688 sslShard->voiceConnectionData.sessionId = this->voiceStateData.sessionId;
689 if (sslShard->areWeCollectingData && !sslShard->stateUpdateCollected && !sslShard->serverUpdateCollected &&
690 this->voiceStateData.userId == sslShard->userId) {
691 sslShard->voiceConnectionData = DiscordCoreInternal::VoiceConnectionData{};
692 sslShard->voiceConnectionData.sessionId = this->voiceStateData.sessionId;
693 sslShard->stateUpdateCollected = true;
694 } else if (sslShard->areWeCollectingData && !sslShard->stateUpdateCollected) {
695 sslShard->voiceConnectionData.sessionId = this->voiceStateData.sessionId;
696 if (sslShard->voiceConnectionDataBuffersMap.contains(this->voiceStateData.guildId.operator size_t())) {
697 sslShard->voiceConnectionDataBuffersMap[this->voiceStateData.guildId.operator size_t()]->send(sslShard->voiceConnectionData);
698 }
699 sslShard->serverUpdateCollected = false;
700 sslShard->stateUpdateCollected = false;
701 sslShard->areWeCollectingData = false;
702 }
703 GuildMembers::insertVoiceState(this->voiceStateData);
704 }
705
706 OnWebhookUpdateData::OnWebhookUpdateData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
707 this->channelId = getId(dataReal["d"], "channel_id");
708 this->guildId = getId(dataReal["d"], "guild_id");
709 }
710
711 OnAutoCompleteEntryData::OnAutoCompleteEntryData(DiscordCoreInternal::WebSocketMessage& data, simdjson::ondemand::value dataReal) {
712 this->inputEvent = data.processJsonMessage<InputEventData>(dataReal, "d");
713 }
714
717 return this->onApplicationCommandPermissionsUpdateEvent.add(std::move(handler));
718 }
719
721 return this->onApplicationCommandPermissionsUpdateEvent.remove(token);
722 }
723
726 return this->onAutoModerationRuleCreationEvent.add(std::move(handler));
727 }
728
730 return this->onAutoModerationRuleCreationEvent.remove(token);
731 }
732
735 return this->onAutoModerationRuleUpdateEvent.add(std::move(handler));
736 }
737
739 return this->onAutoModerationRuleUpdateEvent.remove(token);
740 }
741
744 return this->onAutoModerationRuleDeletionEvent.add(std::move(handler));
745 }
746
748 return this->onAutoModerationRuleDeletionEvent.remove(token);
749 }
750
753 return this->onAutoModerationActionExecutionEvent.add(std::move(handler));
754 }
755
757 return this->onAutoModerationActionExecutionEvent.remove(token);
758 }
759
762 return this->onAutoCompleteEntryEvent.add(std::move(handler));
763 }
764
766 return this->onInputEventCreationEvent.remove(token);
767 }
768
771 return this->onInputEventCreationEvent.add(std::move(handler));
772 }
773
775 return this->onInputEventCreationEvent.remove(token);
776 }
777
780 return this->onChannelCreationEvent.add(std::move(handler));
781 }
782
784 onChannelCreationEvent.remove(token);
785 }
786
789 return this->onChannelUpdateEvent.add(std::move(handler));
790 }
791
793 onChannelUpdateEvent.remove(token);
794 }
795
798 return this->onChannelDeletionEvent.add(std::move(handler));
799 }
800
802 onChannelDeletionEvent.remove(token);
803 }
804
807 return this->onChannelPinsUpdateEvent.add(std::move(handler));
808 }
809
811 return this->onChannelPinsUpdateEvent.remove(token);
812 }
813
816 return this->onThreadCreationEvent.add(std::move(handler));
817 }
818
820 return this->onThreadCreationEvent.remove(token);
821 }
822
825 return this->onThreadUpdateEvent.add(std::move(handler));
826 }
827
829 return this->onThreadUpdateEvent.remove(token);
830 }
831
834 return this->onThreadDeletionEvent.add(std::move(handler));
835 }
836
838 return this->onThreadDeletionEvent.remove(token);
839 }
840
843 return this->onThreadListSyncEvent.add(std::move(handler));
844 }
845
847 return this->onThreadListSyncEvent.remove(token);
848 }
849
852 return this->onThreadMemberUpdateEvent.add(std::move(handler));
853 }
854
856 return this->onThreadMemberUpdateEvent.remove(token);
857 }
858
861 return this->onThreadMembersUpdateEvent.add(std::move(handler));
862 }
863
865 return this->onThreadMembersUpdateEvent.remove(token);
866 }
867
870 return this->onGuildCreationEvent.add(std::move(handler));
871 }
872
874 onGuildCreationEvent.remove(token);
875 }
876
879 return this->onGuildUpdateEvent.add(std::move(handler));
880 }
881
883 onGuildUpdateEvent.remove(token);
884 }
885
888 return this->onGuildDeletionEvent.add(std::move(handler));
889 }
890
892 onGuildDeletionEvent.remove(token);
893 }
894
897 return this->onGuildBanAddEvent.add(std::move(handler));
898 }
899
901 onGuildBanAddEvent.remove(token);
902 }
903
906 return this->onGuildBanRemoveEvent.add(std::move(handler));
907 }
908
910 onGuildBanRemoveEvent.remove(token);
911 }
912
915 return this->onGuildEmojisUpdateEvent.add(std::move(handler));
916 }
917
919 onGuildEmojisUpdateEvent.remove(token);
920 }
921
924 return this->onGuildStickersUpdateEvent.add(std::move(handler));
925 }
926
928 onGuildStickersUpdateEvent.remove(token);
929 }
930
933 return this->onGuildIntegrationsUpdateEvent.add(std::move(handler));
934 }
935
937 onGuildIntegrationsUpdateEvent.remove(token);
938 }
939
942 return this->onGuildMembersChunkEvent.add(std::move(handler));
943 }
944
946 onGuildMembersChunkEvent.remove(token);
947 }
948
951 return this->onGuildMemberAddEvent.add(std::move(handler));
952 }
953
955 onGuildMemberAddEvent.remove(token);
956 }
957
960 return this->onGuildMemberRemoveEvent.add(std::move(handler));
961 }
962
964 onGuildMemberRemoveEvent.remove(token);
965 }
966
969 return this->onGuildMemberUpdateEvent.add(std::move(handler));
970 }
971
973 onGuildMemberUpdateEvent.remove(token);
974 }
975
978 return this->onRoleCreationEvent.add(std::move(handler));
979 }
980
982 onRoleCreationEvent.remove(token);
983 }
984
987 return this->onRoleUpdateEvent.add(std::move(handler));
988 }
989
991 onRoleUpdateEvent.remove(token);
992 }
993
996 return this->onRoleDeletionEvent.add(std::move(handler));
997 }
998
1000 onRoleDeletionEvent.remove(token);
1001 }
1002
1005 return this->onGuildScheduledEventCreationEvent.add(std::move(handler));
1006 }
1007
1009 onGuildScheduledEventCreationEvent.remove(token);
1010 }
1011
1014 return this->onGuildScheduledEventUpdateEvent.add(std::move(handler));
1015 }
1016
1018 onGuildScheduledEventUpdateEvent.remove(token);
1019 }
1020
1023 return this->onGuildScheduledEventDeletionEvent.add(std::move(handler));
1024 }
1025
1027 onGuildScheduledEventDeletionEvent.remove(token);
1028 }
1029
1032 return this->onGuildScheduledEventUserAddEvent.add(std::move(handler));
1033 }
1034
1036 onGuildScheduledEventUserAddEvent.remove(token);
1037 }
1038
1041 return this->onGuildScheduledEventUserRemoveEvent.add(std::move(handler));
1042 }
1043
1045 onGuildScheduledEventUserRemoveEvent.remove(token);
1046 }
1047
1050 return this->onIntegrationCreationEvent.add(std::move(handler));
1051 }
1052
1054 onIntegrationCreationEvent.remove(token);
1055 }
1056
1059 return this->onIntegrationUpdateEvent.add(std::move(handler));
1060 }
1061
1063 onIntegrationUpdateEvent.remove(token);
1064 }
1065
1068 return this->onIntegrationDeletionEvent.add(std::move(handler));
1069 }
1070
1072 onIntegrationDeletionEvent.remove(token);
1073 }
1074
1077 return this->onInteractionCreationEvent.add(std::move(handler));
1078 }
1079
1081 onInteractionCreationEvent.remove(token);
1082 }
1083
1086 return this->onInviteCreationEvent.add(std::move(handler));
1087 }
1088
1090 onInviteCreationEvent.remove(token);
1091 }
1092
1095 return this->onInviteDeletionEvent.add(std::move(handler));
1096 }
1097
1099 onInviteDeletionEvent.remove(token);
1100 }
1101
1104 return this->onMessageCreationEvent.add(std::move(handler));
1105 }
1106
1108 onMessageCreationEvent.remove(token);
1109 }
1110
1113 return this->onMessageUpdateEvent.add(std::move(handler));
1114 }
1115
1117 onMessageUpdateEvent.remove(token);
1118 }
1119
1122 return this->onMessageDeletionEvent.add(std::move(handler));
1123 }
1124
1126 onMessageDeletionEvent.remove(token);
1127 }
1128
1131 return this->onMessageDeleteBulkEvent.add(std::move(handler));
1132 }
1133
1135 onMessageDeleteBulkEvent.remove(token);
1136 }
1137
1140 return this->onReactionAddEvent.add(std::move(handler));
1141 }
1142
1144 onReactionAddEvent.remove(token);
1145 }
1146
1149 return this->onReactionRemoveEvent.add(std::move(handler));
1150 }
1151
1153 onReactionRemoveEvent.remove(token);
1154 }
1155
1158 return this->onReactionRemoveAllEvent.add(std::move(handler));
1159 }
1160
1162 onReactionRemoveAllEvent.remove(token);
1163 }
1164
1167 return this->onReactionRemoveEmojiEvent.add(std::move(handler));
1168 }
1169
1171 onReactionRemoveEmojiEvent.remove(token);
1172 }
1173
1176 return this->onPresenceUpdateEvent.add(std::move(handler));
1177 }
1178
1180 onPresenceUpdateEvent.remove(token);
1181 }
1182
1185 return this->onStageInstanceCreationEvent.add(std::move(handler));
1186 }
1187
1189 onStageInstanceCreationEvent.remove(token);
1190 }
1191
1194 return this->onStageInstanceUpdateEvent.add(std::move(handler));
1195 }
1196
1198 onStageInstanceUpdateEvent.remove(token);
1199 }
1200
1203 return this->onStageInstanceDeletionEvent.add(std::move(handler));
1204 }
1205
1207 onStageInstanceDeletionEvent.remove(token);
1208 }
1209
1212 return this->onTypingStartEvent.add(std::move(handler));
1213 }
1214
1216 onTypingStartEvent.remove(token);
1217 }
1218
1221 return this->onUserUpdateEvent.add(std::move(handler));
1222 }
1223
1225 onUserUpdateEvent.remove(token);
1226 }
1227
1230 return this->onVoiceStateUpdateEvent.add(std::move(handler));
1231 }
1232
1234 onVoiceStateUpdateEvent.remove(token);
1235 }
1236
1239 return this->onVoiceServerUpdateEvent.add(std::move(handler));
1240 }
1241
1243 onVoiceServerUpdateEvent.remove(token);
1244 }
1245
1248 return this->onWebhookUpdateEvent.add(std::move(handler));
1249 }
1250
1252 onWebhookUpdateEvent.remove(token);
1253 }
1254
1255};
@ Role_Select
Select menu for roles.
@ Mentionable_Select
Select menu for mentionables (users and roles).
@ Channel_Select
Select menu for channels.
@ String_Select
Select menu for picking from defined text options.
@ User_Select
Select menu for users.
@ Message_Component
Message component.
@ Application_Command_Autocomplete
Application command autocomplete.
@ Application_Command
Application command.
@ Modal_Submit
Modal submission.
The main namespace for this library.
A CoRoutine - representing a potentially asynchronous operation/function.
Definition: CoRoutine.hpp:59
Event-delegate token, representing an event.
Event-delegate, for representing an event-function to be executed.
Data that is received as part of an InputEvent creation event.
InputEventData inputEventData
InputEventData representing the input-event.
Data that is received as part of an ApplicationCommandPermissions update event.
Data that is received as part of an AutoModerationRule creation event.
Data that is received as part of an AutoModerationRule update event.
Data that is received as part of an AutoModerationRule delete event.
Data that is received as part of an AutoModerationAction execution event.
Data that is received as part of a Channel creation event.
std::unique_ptr< ChannelData > channel
The new Channel.
Data that is received as part of a Channel update event.
std::unique_ptr< ChannelData > channel
The new Channel.
Data that is received as part of a Channel deletion event.
std::unique_ptr< ChannelData > channel
The deleted Channel.
Data that is received as part of a Channel pins update event.
ChannelPinsUpdateEventData dataPackage
The Channel pins update responseData.
Data that is received as part of a Thread creation event.
Thread thread
The new Thread's Channel.
Data that is received as part of a Thread update event.
Thread thread
The new Thread's Channel.
Data that is received as part of a Thread deletion event.
Thread thread
The deleted Thread's Channel.
Data that is received as part of a Thread list sync event.
ThreadListSyncData threadListSyncData
The Thread list sync responseData.
Data that is received as part of a Thread member update event.
ThreadMemberData threadMember
Thread member update responseData.
Data that is received as part of a Thread members update event.
ThreadMembersUpdateData threadMembersUpdateData
Thread member's update responseData.
Data that is received as part of a Guild creation event.
std::unique_ptr< GuildData > guild
The new Guild.
Data that is received as part of a Guild update event.
std::unique_ptr< GuildData > guild
The new Guild.
Data that is received as part of a Guild deletion event.
std::unique_ptr< GuildData > guild
The deleted Guild.
Data that is received as part of a Guild ban add event.
Snowflake guildId
The Guild they were banned from.
User user
The User id of the person who was banned.
Data that is received as part of a Guild ban add event.
Snowflake guildId
The Guild they were un-banned from.
User user
The User id of the person who was un-banned.
Data that is received as part of a Guild emojis update event.
GuildEmojisUpdateEventData updateData
The Guild emoji's update responseData.
Data that is received as part of a Guild sticker update event.
GuildStickersUpdateEventData updateData
The GuildStickersUpdateEventData.
Data that is received as part of a Guild Integration update event.
Snowflake guildId
The id of the Guild for which the integrations were updated.
Data that is received as part of a GuildMember add event.
std::unique_ptr< GuildMemberData > guildMember
The new GuildMember.
Data that is received as part of a GuildMember update event.
Data that is received as part of a GuildMember remove event.
std::unique_ptr< UserData > user
The User responseData of the removed GuildMember.
Snowflake guildId
The id of the Guild from which they were removed.
Data that is received as part of a GuildMembers chunk event.
GuildMembersChunkEventData chunkEventData
GuildMembersChunkEventData structure.
Data that is received as part of a Role creation event.
Snowflake guildId
The id of the Guild within which the Role was created.
std::unique_ptr< RoleData > role
The new Role.
Data that is received as part of a Role update event.
std::unique_ptr< RoleData > role
The new Role.
Snowflake guildId
The id of the Guild within which the Role was updated.
Data that is received as part of a Role deletion event.
std::unique_ptr< RoleData > role
The deleted Role.
Snowflake guildId
The id of the Guild from which the Role was deleted.
Data that is received as part of a GuildScheduledEvent creation event.
Data that is received as part of a GuildScheduledEvent update event.
Data that is received as part of a GuildScheduledEvent delete event.
Data that is received as part of a GuildScheduledEvent User add event.
Data that is received as part of a GuildScheduledEvent User remove event.
Data that is received as part of an Integration creation event.
Snowflake guildId
The id of the Guild for which this Integration was created.
IntegrationData integrationData
The new IntegrationData structure.
Data that is received as part of an Integration update event.
IntegrationData integrationData
New IntegrationData structure.
Snowflake guildId
The id of the Guild for which the Integration was updated.
Data that is received as part of an Integration deletion event.
Snowflake applicationId
Application id of the current application.
Snowflake guildId
The id of the Guild for which the Integration was deleted.
Data that is received as part of an Invite creation event.
InviteData invite
Thew new InviteData structure.
Data that is received as part of an Invite deletion event.
Snowflake guildId
The id of the Guild for which the Invite existed.
std::string code
The code of the Invite.
Snowflake channelId
The id of the Channel for which the Invite existed.
Data that is received as part of an Interaction creation event.
InteractionData interactionData
The InteractionData representing the Interaction.
Data that is received as part of a Message creation event.
Data that is received as part of a Message update event.
Message messageNew
The new Message.
Data that is received as part of a Message deletion event.
Snowflake guildId
The id of the Guild from which the Message was deleted.
Snowflake messageId
The id of the Message which was deleted.
Snowflake channelId
The id of the Channel from which the Message was deleted.
Data that is received as part of a Message delete bulk event.
std::vector< Snowflake > ids
A vector containing the list of deleted Message ids.
Snowflake channelId
The id of the Channel from which the Message was deleted.
Snowflake guildId
The id of the Guild from which the Message was deleted.
Data that is received as part of a Reaction add event.
Reaction reaction
The Reaction that was added.
Data that is received as part of a Reaction remove event.
ReactionRemoveData reactionRemoveData
The ReactionRemoveData.
Data that is received as part of a Reaction remove all event.
Snowflake messageId
The id of the Message from which the Reactions were deleted.
Snowflake channelId
The id of the Channel from which the Reactions were deleted.
Snowflake guildId
The id of the Guild from which the Reactions were deleted.
Data that is received as part of a Reaction remove emoji event.
Snowflake guildId
The id of the Guild from which the Reactions were deleted.
Snowflake messageId
The id of the Message from which the Reactions were deleted.
EmojiData emoji
The id of the Emoji which was removed from the Message.
Snowflake channelId
The id of the Channel from which the Reactions were deleted.
Data that is received as part of a presence update event.
PresenceUpdateData presenceData
PresenceUpdateData..
Data that is received as part of a StageInstance creation event.
StageInstanceData stageInstance
The new StageInstanceData.
Data that is received as part of a StageInstance update event.
StageInstanceData stageInstance
The new StageInstanceData.
Data that is received as part of a StageInstance deletion event.
StageInstanceData stageInstance
The deleted StageInstanceData.
Data that is received as part of a typing start event.
TypingStartData typingStartData
TypingStartData of the event.
Data that is received as part of a User update event.
std::unique_ptr< UserData > user
The new User.
Data that is received as part of a voice state update event.
VoiceStateData voiceStateData
VoiceStateData for the new voice state.
Data that is received as part of a voice server update event.
Snowflake guildId
The id of the Guild for which the server update is occurring.
std::string token
The token of the server update event.
std::string endpoint
The new endpoint.
Data that is received as part of a WebHook update event.
Snowflake guildId
Id of the Guild for which the WebHook Update is occurring.
Snowflake channelId
Id of the Channel for which the WebHook Update is occurring.
Data that is received upon the bot receiving an autocomplete entry.
InputEventData inputEvent
The input-event representing the autocomplete entry.
DiscordCoreInternal::EventDelegateToken onStageInstanceUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnStageInstanceUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onChannelUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnChannelUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onAutoModerationActionExecution(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnAutoModerationActionExecutionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onApplicationCommandsPermissionsUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnApplicationCommandPermissionsUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildBanRemove(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildBanRemoveData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onChannelDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnChannelDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onVoiceServerUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnVoiceServerUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onMessageDeleteBulk(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnMessageDeleteBulkData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onMessageUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnMessageUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onInputEventCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnInputEventCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onWebhookUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnWebhookUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildEmojisUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildEmojisUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildMemberAdd(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildMemberAddData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onThreadUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnThreadUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onReactionAdd(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnReactionAddData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildScheduledEventDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildScheduledEventDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onThreadCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnThreadCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildMemberUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildMemberUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onInviteCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnInviteCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onUserUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnUserUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onThreadDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnThreadDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onStageInstanceDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnStageInstanceDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onAutoModerationRuleUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnAutoModerationRuleUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onInviteDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnInviteDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onThreadMembersUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnThreadMembersUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onStageInstanceCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnStageInstanceCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildScheduledEventUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildScheduledEventUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onReactionRemoveEmoji(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnReactionRemoveEmojiData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onAutoModerationRuleCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnAutoModerationRuleCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onReactionRemove(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnReactionRemoveData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildScheduledEventUserRemove(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildScheduledEventUserRemoveData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onChannelPinsUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnChannelPinsUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onAutoCompleteEntry(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnAutoCompleteEntryData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildIntegrationsUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildIntegrationsUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onMessageCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnMessageCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildMemberRemove(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildMemberRemoveData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onRoleDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnRoleDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onPresenceUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnPresenceUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onReactionRemoveAll(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnReactionRemoveAllData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onChannelCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnChannelCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onRoleUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnRoleUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onThreadMemberUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnThreadMemberUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildScheduledEventCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildScheduledEventCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildBanAdd(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildBanAddData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildMembersChunk(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildMembersChunkData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onInteractionCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnInteractionCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onTypingStart(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnTypingStartData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onVoiceStateUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnVoiceStateUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onRoleCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnRoleCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onIntegrationDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnIntegrationDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildScheduledEventUserAdd(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildScheduledEventUserAddData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onThreadListSync(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnThreadListSyncData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onAutoModerationRuleDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnAutoModerationRuleDeletionData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onIntegrationCreation(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnIntegrationCreationData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onGuildStickersUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnGuildStickersUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onIntegrationUpdate(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnIntegrationUpdateData > handler)
For adding a function to handle this event.
DiscordCoreInternal::EventDelegateToken onMessageDeletion(const DiscordCoreInternal::EventDelegate< CoRoutine< void >, OnMessageDeletionData > handler)
For adding a function to handle this event.
Snowflake guildId
The Guild id this voice state is for.
std::string sessionId
The session id for this voice state.
Snowflake guildId
Id of the Channel's Guild, if applicable.
Snowflake guildId
The Guild id for which the Channel exists in.
Snowflake guildId
The Guild id which the scheduled event belongs to.
ComponentType componentType
The type of component.
ComponentInteractionData componentData
Component Interaction data.
InteractionDataData data
The Interaction's data.
InteractionType type
The type of Interaction.
static GuildMemberData getCachedGuildMember(GetGuildMemberData dataPackage)
Collects a GuildMember from the library's cache.
static RoleData getCachedRole(GetRoleData dataPackage)
Collects a given Role from the library's cache.