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, Value data) {
34 this->inputEventData = message.processJsonMessage<InputEventData>(std::move(data), "d");
35 }
36
37 OnApplicationCommandPermissionsUpdateData::OnApplicationCommandPermissionsUpdateData(DiscordCoreInternal::WebSocketMessage& message,
38 Value data) {
39 this->permissionData = message.processJsonMessage<GuildApplicationCommandPermissionsData>(std::move(data), "d");
40 }
41
42 OnAutoModerationRuleCreationData::OnAutoModerationRuleCreationData(DiscordCoreInternal::WebSocketMessage& message, Value data) {
43 this->theRule = message.processJsonMessage<AutoModerationRule>(std::move(data), "d");
44 }
45
46 OnAutoModerationRuleUpdateData::OnAutoModerationRuleUpdateData(DiscordCoreInternal::WebSocketMessage& message, Value data) {
47 this->theRule = message.processJsonMessage<AutoModerationRule>(std::move(data), "d");
48 }
49
50 OnAutoModerationRuleDeletionData::OnAutoModerationRuleDeletionData(DiscordCoreInternal::WebSocketMessage& message, Value data) {
51 this->theRule = message.processJsonMessage<AutoModerationRule>(std::move(data), "d");
52 }
53
54 OnAutoModerationActionExecutionData::OnAutoModerationActionExecutionData(DiscordCoreInternal::WebSocketMessage& message, Value data) {
55 this->data = message.processJsonMessage<AutoModerationActionExecutionEventData>(std::move(data), "d");
56 }
57
58 OnChannelCreationData::OnChannelCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
59 this->channel = std::make_unique<ChannelData>(data.processJsonMessage<ChannelData>(std::move(dataReal), "d"));
60 if (Channels::doWeCacheChannels()) {
61 GuildData guild{};
62 guild.id = this->channel->guildId;
63 if (Guilds::getCache().contains(guild)) {
64 Guilds::getCache()[guild].channels.emplace_back(this->channel->id);
65 }
66 if (Channels::doWeCacheChannels()) {
67 Channels::insertChannel(*this->channel);
68 }
69 }
70 }
71
72 OnChannelCreationData& OnChannelCreationData::operator=(const OnChannelCreationData& other) {
73 *this->channel = *other.channel;
74 return *this;
75 }
76
77 OnChannelCreationData::OnChannelCreationData(const OnChannelCreationData& other) {
78 *this = other;
79 }
80
81 OnChannelUpdateData::OnChannelUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
82 this->channel = std::make_unique<ChannelData>(data.processJsonMessage<ChannelData>(std::move(dataReal), "d"));
83 if (Channels::doWeCacheChannels()) {
84 Channels::insertChannel(*this->channel);
85 }
86 }
87
88 OnChannelUpdateData& OnChannelUpdateData::operator=(const OnChannelUpdateData& other) {
89 *this->channel = *other.channel;
90 return *this;
91 }
92
93 OnChannelUpdateData::OnChannelUpdateData(const OnChannelUpdateData& other) {
94 *this = other;
95 }
96
97 OnChannelDeletionData::OnChannelDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
98 this->channel = std::make_unique<ChannelData>(data.processJsonMessage<ChannelData>(std::move(dataReal), "d"));
99 if (Channels::doWeCacheChannels()) {
100 GuildData guild{};
101 guild.id = this->channel->guildId;
102 if (Guilds::getCache().contains(guild)) {
103 for (uint64_t x = 0; x < Guilds::getCache()[guild].channels.size(); ++x) {
104 if (Guilds::getCache()[guild].channels[x] == this->channel->id) {
105 Guilds::getCache()[guild].channels.erase(Guilds::getCache()[guild].channels.begin() + x);
106 }
107 }
108 }
109 if (Channels::doWeCacheChannels()) {
110 Channels::removeChannel(this->channel->id);
111 }
112 }
113 }
114
115 OnChannelDeletionData& OnChannelDeletionData::operator=(const OnChannelDeletionData& other) {
116 *this->channel = *other.channel;
117 return *this;
118 }
119
120 OnChannelDeletionData::OnChannelDeletionData(const OnChannelDeletionData& other) {
121 *this = other;
122 }
123
124 OnChannelPinsUpdateData::OnChannelPinsUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
125 this->dataPackage = data.processJsonMessage<ChannelPinsUpdateEventData>(std::move(dataReal), "d");
126 }
127
128 OnThreadCreationData::OnThreadCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
129 this->thread = data.processJsonMessage<Thread>(std::move(dataReal), "d");
130 GuildData guild{};
131 guild.id = this->thread.guildId;
132 if (Guilds::getCache().contains(guild)) {
133 Guilds::getCache()[guild].threads.emplace_back(this->thread.id);
134 }
135 }
136
137 OnThreadUpdateData::OnThreadUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
138 this->thread = data.processJsonMessage<Thread>(std::move(dataReal), "d");
139 }
140
141 OnThreadDeletionData::OnThreadDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
142 this->thread = data.processJsonMessage<Thread>(std::move(dataReal), "d");
143 GuildData guild{};
144 guild.id = this->thread.guildId;
145 if (Guilds::getCache().contains(guild)) {
146 for (uint64_t x = 0; x < Guilds::getCache()[guild].threads.size(); ++x) {
147 if (Guilds::getCache()[guild].threads[x] == this->thread.id) {
148 Guilds::getCache()[guild].threads.erase(Guilds::getCache()[guild].threads.begin() + x);
149 }
150 }
151 }
152 }
153
154 OnThreadListSyncData::OnThreadListSyncData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
155 this->threadListSyncData = data.processJsonMessage<ThreadListSyncData>(std::move(dataReal), "d");
156 }
157
158 OnThreadMemberUpdateData::OnThreadMemberUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
159 this->threadMember = data.processJsonMessage<ThreadMemberData>(std::move(dataReal), "d");
160 }
161
162 OnThreadMembersUpdateData::OnThreadMembersUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
163 this->threadMembersUpdateData = data.processJsonMessage<ThreadMembersUpdateData>(std::move(dataReal), "d");
164 }
165
166 OnGuildCreationData::OnGuildCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal, DiscordCoreClient* client) {
167 this->guild = std::make_unique<GuildData>(data.processJsonMessage<GuildData>(std::move(dataReal), "d"));
168 this->guild->discordCoreClient = client;
169 if (Guilds::doWeCacheGuilds()) {
170 if (Guilds::doWeCacheGuilds()) {
171 Guilds::insertGuild(*this->guild);
172 }
173 }
174 }
175
176 OnGuildCreationData& OnGuildCreationData::operator=(const OnGuildCreationData& other) {
177 *this->guild = *other.guild;
178 return *this;
179 }
180
181 OnGuildCreationData::OnGuildCreationData(const OnGuildCreationData& other) {
182 *this = other;
183 }
184
185 OnGuildUpdateData::OnGuildUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal, DiscordCoreClient* clientNew) {
186 this->guild = std::make_unique<GuildData>(data.processJsonMessage<GuildData>(std::move(dataReal), "d"));
187 this->guild->discordCoreClient = clientNew;
188 if (Guilds::doWeCacheGuilds()) {
189 Guilds::insertGuild(*this->guild);
190 }
191 }
192
193 OnGuildUpdateData& OnGuildUpdateData::operator=(const OnGuildUpdateData& other) {
194 *this->guild = *other.guild;
195 return *this;
196 }
197
198 OnGuildUpdateData::OnGuildUpdateData(const OnGuildUpdateData& other) {
199 *this = other;
200 }
201
202 OnGuildDeletionData::OnGuildDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal, DiscordCoreClient* clientNew) {
203 this->guild = std::make_unique<GuildData>(data.processJsonMessage<GuildData>(std::move(dataReal), "d"));
204 if (Guilds::doWeCacheGuilds()) {
205 Guilds::removeGuild(this->guild->id);
206 }
207 for (auto& valueNew: this->guild->members) {
208 GuildMemberData guildMember = GuildMembers::getCachedGuildMember({ .guildMemberId = valueNew, .guildId = this->guild->id });
209 GuildMembers::removeGuildMember(guildMember);
210 }
211 for (auto& valueNew: this->guild->channels) {
212 Channels::removeChannel(valueNew);
213 }
214 for (auto& valueNew: this->guild->roles) {
215 Roles::removeRole(valueNew);
216 }
217 }
218
219 OnGuildDeletionData& OnGuildDeletionData::operator=(const OnGuildDeletionData& other) {
220 *this->guild = *other.guild;
221 return *this;
222 }
223
224 OnGuildDeletionData::OnGuildDeletionData(const OnGuildDeletionData& other) {
225 *this = other;
226 }
227
228 OnGuildBanAddData::OnGuildBanAddData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
229 this->guildId = getId(dataReal["d"].value(), "guild_id");
230 this->user = data.processJsonMessage<UserData>(dataReal["d"].value(), "user");
231 }
232
233 OnGuildBanRemoveData::OnGuildBanRemoveData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
234 this->guildId = getId(dataReal["d"].value(), "guild_id");
235 this->user = data.processJsonMessage<UserData>(dataReal["d"].value(), "user");
236 }
237
238 OnGuildEmojisUpdateData::OnGuildEmojisUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
239 this->updateData = data.processJsonMessage<GuildEmojisUpdateEventData>(std::move(dataReal), "d");
240 GuildData guild{};
241 guild.id = this->updateData.guildId;
242 if (Guilds::getCache().contains(guild)) {
243 Guilds::getCache()[guild].emoji.clear();
244 for (auto& valueNew: this->updateData.emojis) {
245 Guilds::getCache()[guild].emoji.emplace_back(valueNew.id);
246 }
247 }
248 }
249
250 OnGuildStickersUpdateData::OnGuildStickersUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
251 this->updateData = data.processJsonMessage<GuildStickersUpdateEventData>(std::move(dataReal), "d");
252 GuildData guild{};
253 guild.id = this->updateData.guildId;
254 if (Guilds::getCache().contains(guild)) {
255 Guilds::getCache()[guild].stickers.clear();
256 for (auto& valueNew: this->updateData.stickers) {
257 Guilds::getCache()[guild].stickers.emplace_back(valueNew.id);
258 }
259 }
260 }
261
262 OnGuildIntegrationsUpdateData::OnGuildIntegrationsUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
263 this->guildId = getId(dataReal["d"].value(), "guild_id");
264 }
265
266 OnGuildMemberAddData::OnGuildMemberAddData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal, DiscordCoreClient* client) {
267 this->guildMember = std::make_unique<GuildMemberData>(data.processJsonMessage<GuildMemberData>(std::move(dataReal), "d"));
268 this->discordCoreClient = client;
269 if (GuildMembers::doWeCacheGuildMembers()) {
270 GuildMembers::insertGuildMember(*this->guildMember);
271 GuildData guild{};
272 guild.id = guildMember->guildId;
273 if (Guilds::getCache().contains(guild)) {
274 ++Guilds::getCache()[guild].memberCount;
275 }
276 }
277 }
278
279 OnGuildMemberAddData& OnGuildMemberAddData::operator=(const OnGuildMemberAddData& other) {
280 this->discordCoreClient = other.discordCoreClient;
281 *this->guildMember = *other.guildMember;
282 return *this;
283 }
284
285 OnGuildMemberAddData::OnGuildMemberAddData(const OnGuildMemberAddData& other) {
286 *this = other;
287 }
288
289 OnGuildMemberRemoveData::OnGuildMemberRemoveData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal,
290 DiscordCoreClient* client) {
291 this->discordCoreClient = client;
292 this->guildId = getId(dataReal["d"].value(), "guild_id");
293 this->user = std::make_unique<UserData>(data.processJsonMessage<UserData>(dataReal["d"].value(), "user"));
294 GuildMember guildMember = GuildMembers::getCachedGuildMember({ .guildMemberId = this->user->id, .guildId = this->guildId });
295 if (GuildMembers::doWeCacheGuildMembers()) {
296 GuildData guild{};
297 guild.id = this->guildId;
298 GuildMembers::removeGuildMember(guildMember);
299 if (Guilds::getCache().contains(guild)) {
300 for (uint64_t x = 0; x < Guilds::getCache()[guild].members.size(); ++x) {
301 if (Guilds::getCache()[guild].members[x] == this->user->id) {
302 --Guilds::getCache()[guild].memberCount;
303 Guilds::getCache()[guild].members.erase(Guilds::getCache()[guild].members.begin() + x);
304 }
305 }
306 }
307 }
308 }
309
310 OnGuildMemberRemoveData& OnGuildMemberRemoveData::operator=(const OnGuildMemberRemoveData& other) {
311 this->discordCoreClient = other.discordCoreClient;
312 this->guildId = other.guildId;
313 *this->user = *other.user;
314 return *this;
315 }
316
317 OnGuildMemberRemoveData::OnGuildMemberRemoveData(const OnGuildMemberRemoveData& other) {
318 *this = other;
319 }
320
321 OnGuildMemberUpdateData::OnGuildMemberUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal,
322 DiscordCoreClient* client) {
323 this->guildMember = std::make_unique<GuildMemberData>(data.processJsonMessage<GuildMemberData>(std::move(dataReal), "d"));
324 if (GuildMembers::doWeCacheGuildMembers()) {
325 GuildMembers::insertGuildMember(*this->guildMember);
326 }
327 }
328
329 OnGuildMemberUpdateData& OnGuildMemberUpdateData::operator=(const OnGuildMemberUpdateData& other) {
330 *this->guildMember = *other.guildMember;
331 return *this;
332 }
333
334 OnGuildMemberUpdateData::OnGuildMemberUpdateData(const OnGuildMemberUpdateData& other) {
335 *this = other;
336 }
337
338 OnGuildMembersChunkData::OnGuildMembersChunkData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
339 this->chunkEventData = data.processJsonMessage<GuildMembersChunkEventData>(std::move(dataReal), "d");
340 }
341
342 OnRoleCreationData::OnRoleCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
343 this->guildId = getId(dataReal["d"].value(), "guild_id");
344 this->role = std::make_unique<RoleData>(data.processJsonMessage<RoleData>(dataReal["d"].value(), "role"));
345 GuildData guild{};
346 guild.id = guildId;
347 if (Guilds::getCache().contains(guild)) {
348 Guilds::getCache()[guild].roles.emplace_back(this->role->id);
349 }
350 if (Roles::doWeCacheRoles()) {
351 Roles::insertRole(*this->role);
352 }
353 }
354
355 OnRoleCreationData& OnRoleCreationData::operator=(const OnRoleCreationData& other) {
356 this->guildId = other.guildId;
357 *this->role = *other.role;
358 return *this;
359 }
360
361 OnRoleCreationData::OnRoleCreationData(const OnRoleCreationData& other) {
362 *this = other;
363 }
364
365 OnRoleUpdateData::OnRoleUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
366 this->guildId = getId(dataReal["d"].value(), "guild_id");
367 this->role = std::make_unique<RoleData>(data.processJsonMessage<RoleData>(dataReal["d"].value(), "role"));
368 if (Roles::doWeCacheRoles()) {
369 Roles::insertRole(*this->role);
370 }
371 }
372
373 OnRoleUpdateData& OnRoleUpdateData::operator=(const OnRoleUpdateData& other) {
374 this->guildId = other.guildId;
375 *this->role = *other.role;
376 return *this;
377 }
378
379 OnRoleUpdateData::OnRoleUpdateData(const OnRoleUpdateData& other) {
380 *this = other;
381 }
382
383 OnRoleDeletionData::OnRoleDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
384 this->role->id = getId(dataReal["d"].value(), "role_id");
385 this->guildId = getId(dataReal["d"].value(), "guild_id");
386 this->role = std::make_unique<RoleData>(Roles::getCachedRole({ .guildId = this->guildId, .roleId = this->role->id }));
387 GuildData guild{};
388 guild.id = this->guildId;
389 if (Roles::doWeCacheRoles()) {
390 Roles::removeRole(this->role->id);
391 if (Guilds::getCache().contains(guild)) {
392 for (uint64_t x = 0; x < Guilds::getCache()[guild].roles.size(); ++x) {
393 if (Guilds::getCache()[guild].roles[x] == this->role->id) {
394 Guilds::getCache()[guild].roles.erase(Guilds::getCache()[guild].roles.begin() + x);
395 }
396 }
397 }
398 }
399 }
400
401 OnRoleDeletionData& OnRoleDeletionData::operator=(const OnRoleDeletionData& other) {
402 this->guildId = other.guildId;
403 *this->role = *other.role;
404 return *this;
405 }
406
407 OnRoleDeletionData::OnRoleDeletionData(const OnRoleDeletionData& other) {
408 *this = other;
409 }
410
411 OnUserUpdateData& OnUserUpdateData::operator=(const OnUserUpdateData& other) {
412 *this->user = *other.user;
413 return *this;
414 }
415
416 OnUserUpdateData::OnUserUpdateData(const OnUserUpdateData& other) {
417 *this = other;
418 }
419
420 OnVoiceServerUpdateData::OnVoiceServerUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal,
421 DiscordCoreInternal::WebSocketClient* sslShard) {
422 this->endpoint = getString(dataReal["d"].value(), "endpoint");
423 this->guildId = getId(dataReal["d"].value(), "guild_id");
424 this->token = getString(dataReal["d"].value(), "token");
425 sslShard->voiceConnectionData.endPoint = this->endpoint;
426 sslShard->voiceConnectionData.token = this->token;
427 if (sslShard->areWeCollectingData && !sslShard->serverUpdateCollected && !sslShard->stateUpdateCollected) {
428 sslShard->voiceConnectionData = DiscordCoreInternal::VoiceConnectionData{};
429 sslShard->serverUpdateCollected = true;
430 } else if (sslShard->areWeCollectingData && !sslShard->serverUpdateCollected) {
431 if (sslShard->voiceConnectionDataBuffersMap.contains(this->guildId.operator size_t())) {
432 sslShard->voiceConnectionDataBuffersMap[this->guildId.operator size_t()]->send(sslShard->voiceConnectionData);
433 }
434 sslShard->serverUpdateCollected = false;
435 sslShard->stateUpdateCollected = false;
436 sslShard->areWeCollectingData = false;
437 }
438 };
439
440 OnGuildScheduledEventCreationData::OnGuildScheduledEventCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
441 this->guildScheduledEvent = data.processJsonMessage<GuildScheduledEventData>(std::move(dataReal), "d");
442 GuildData guild{};
443 guild.id = this->guildScheduledEvent.guildId;
444 if (Guilds::getCache().contains(guild)) {
445 Guilds::getCache()[guild].guildScheduledEvents.emplace_back(this->guildScheduledEvent.id);
446 }
447 }
448
449 OnGuildScheduledEventUpdateData::OnGuildScheduledEventUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
450 this->guildScheduledEvent = data.processJsonMessage<GuildScheduledEventData>(std::move(dataReal), "d");
451 }
452
453 OnGuildScheduledEventDeletionData::OnGuildScheduledEventDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
454 this->guildScheduledEvent = data.processJsonMessage<GuildScheduledEventData>(std::move(dataReal), "d");
455 GuildData guild{};
456 guild.id = this->guildScheduledEvent.guildId;
457 if (Guilds::getCache().contains(guild)) {
458 for (uint64_t x = 0; x < Guilds::getCache()[guild].guildScheduledEvents.size(); ++x) {
459 if (Guilds::getCache()[guild].guildScheduledEvents[x] == this->guildScheduledEvent.id) {
460 Guilds::getCache()[guild].guildScheduledEvents.erase(Guilds::getCache()[guild].guildScheduledEvents.begin() + x);
461 }
462 }
463 }
464 }
465
466 OnGuildScheduledEventUserAddData::OnGuildScheduledEventUserAddData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
467 this->guildScheduledEventId = getId(dataReal["d"].value(), "guild_scheduled_event_id");
468 this->guildId = getId(dataReal["d"].value(), "guild_id");
469 this->userId = getId(dataReal["d"].value(), "user_id");
470 }
471
472 OnGuildScheduledEventUserRemoveData::OnGuildScheduledEventUserRemoveData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
473 this->guildScheduledEventId = getId(dataReal["d"].value(), "guild_scheduled_event_id");
474 this->guildId = getId(dataReal["d"].value(), "guild_id");
475 this->userId = getId(dataReal["d"].value(), "user_id");
476 }
477
478 OnIntegrationCreationData::OnIntegrationCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
479 this->guildId = getId(dataReal["d"].value(), "guild_id");
480 Value objectNew{};
481 if (dataReal["d"]["integration"].get(objectNew) == ErrorCode::Success) {
482 this->integrationData = IntegrationData{ objectNew };
483 }
484 }
485
486 OnIntegrationUpdateData::OnIntegrationUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
487 this->guildId = getId(dataReal["d"].value(), "guild_id");
488 Value objectNew{};
489 if (dataReal["d"]["integration"].get(objectNew) == ErrorCode::Success) {
490 this->integrationData = IntegrationData{ objectNew };
491 }
492 }
493
494 OnIntegrationDeletionData::OnIntegrationDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
495 this->applicationId = getId(dataReal["d"].value(), "application_id");
496 this->guildId = getId(dataReal["d"].value(), "guild_id");
497 this->id = getId(dataReal["d"].value(), "id");
498 }
499
500 OnInteractionCreationData::OnInteractionCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal,
501 DiscordCoreClient* clientPtr) {
502 this->interactionData = InteractionData{ data.processJsonMessage<InteractionData>(std::move(dataReal), "d") };
503 std::unique_ptr<InputEventData> eventData{ std::make_unique<InputEventData>(interactionData) };
504 switch (interactionData.type) {
506 eventData->responseType = InputEventResponseType::Unset;
507 *eventData->interactionData = this->interactionData;
508 std::unique_ptr<CommandData> commandData{ std::make_unique<CommandData>(*eventData) };
509 commandData->discordCoreClient = eventData->getGuildData().discordCoreClient;
510 clientPtr->getCommandController().checkForAndRunCommand(*commandData);
511 std::unique_ptr<OnInputEventCreationData> eventCreationData{ std::make_unique<OnInputEventCreationData>(data,
512 std::move(dataReal)) };
513 eventCreationData->inputEventData = *eventData;
514 break;
515 }
519 eventData->responseType = InputEventResponseType::Unset;
520 *eventData->interactionData = this->interactionData;
521 if (ButtonCollector::buttonInteractionBuffersMap.contains(
522 eventData->getChannelData().id + eventData->getMessageData().id)) {
523 ButtonCollector::buttonInteractionBuffersMap[eventData->getChannelData().id + eventData->getMessageData().id]
524 ->send(interactionData);
525 }
526 ButtonCollector::buttonInteractionEventsMap.operator()(*eventData->interactionData);
527 break;
528 }
534 eventData->responseType = InputEventResponseType::Unset;
535 *eventData->interactionData = this->interactionData;
536 if (SelectMenuCollector::selectMenuInteractionBuffersMap.contains(
537 eventData->getChannelData().id + eventData->getMessageData().id)) {
538 SelectMenuCollector::selectMenuInteractionBuffersMap[eventData->getChannelData().id +
539 eventData->getMessageData().id]
540 ->send(interactionData);
541 }
542 SelectMenuCollector::selectMenuInteractionEventsMap.operator()(*eventData->interactionData);
543 break;
544 }
545 }
546 break;
547 }
549 eventData->responseType = InputEventResponseType::Unset;
550 *eventData->interactionData = this->interactionData;
551 std::unique_ptr<OnInputEventCreationData> eventCreationData{ std::make_unique<OnInputEventCreationData>(data,
552 std::move(dataReal)) };
553 eventCreationData->inputEventData = *eventData;
554 if (ModalCollector::modalInteractionBuffersMap.contains(eventData->getChannelData().id)) {
555 ModalCollector::modalInteractionBuffersMap[eventData->getChannelData().id]->send(eventData->getInteractionData());
556 ModalCollector::modalInteractionEventsMap.operator()(*eventData->interactionData);
557 }
558 break;
559 }
561 eventData->responseType = InputEventResponseType::Unset;
562 *eventData->interactionData = this->interactionData;
563 std::unique_ptr<OnAutoCompleteEntryData> autocompleteEntryData{ std::make_unique<OnAutoCompleteEntryData>(data,
564 std::move(dataReal)) };
565 autocompleteEntryData->inputEvent = *eventData;
566 clientPtr->getEventManager().onAutoCompleteEntryEvent(*autocompleteEntryData);
567 break;
568 }
569 }
570 }
571
572 OnInviteCreationData::OnInviteCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
573 this->invite = data.processJsonMessage<InviteData>(std::move(dataReal), "d");
574 }
575
576 OnInviteDeletionData::OnInviteDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
577 this->channelId = getId(dataReal["d"].value(), "channel_id");
578 this->guildId = getId(dataReal["d"].value(), "guild_id");
579 this->code = getId(dataReal["d"].value(), "code");
580 }
581
582 OnMessageCreationData::OnMessageCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
583 this->message = data.processJsonMessage<Message>(std::move(dataReal), "d");
584 for (auto& [key, dValue]: MessageCollector::objectsBuffersMap) {
585 dValue->send(this->message);
586 }
587 }
588
589 OnMessageUpdateData::OnMessageUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
590 this->messageNew = data.processJsonMessage<Message>(std::move(dataReal), "d");
591 for (auto& [key, dValue]: MessageCollector::objectsBuffersMap) {
592 dValue->send(this->messageNew);
593 }
594 }
595
596 OnMessageDeletionData::OnMessageDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
597 this->channelId = getId(dataReal["d"].value(), "channel_id");
598 this->guildId = getId(dataReal["d"].value(), "guild_id");
599 this->messageId = getId(dataReal["d"].value(), "id");
600 }
601
602 OnMessageDeleteBulkData::OnMessageDeleteBulkData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
603 this->channelId = getId(dataReal["d"].value(), "channel_id");
604 this->guildId = getId(dataReal["d"].value(), "guild_id");
605 Array arrayValue{};
606 if (dataReal["d"]["ids"].get(arrayValue) == ErrorCode::Success) {
607 for (auto dValue: arrayValue) {
608 this->ids.emplace_back(strtoull(dValue.getString().value()));
609 }
610 }
611 }
612
613 OnReactionAddData::OnReactionAddData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
614 this->reaction = data.processJsonMessage<Reaction>(std::move(dataReal), "d");
615 }
616
617 OnReactionRemoveData::OnReactionRemoveData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
618 this->reactionRemoveData = data.processJsonMessage<ReactionRemoveData>(std::move(dataReal), "d");
619 }
620
621 OnReactionRemoveAllData::OnReactionRemoveAllData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
622 this->messageId = getId(dataReal["d"].value(), "message_id");
623 this->channelId = getId(dataReal["d"].value(), "channel_id");
624 this->guildId = getId(dataReal["d"].value(), "guild_id");
625 }
626
627 OnReactionRemoveEmojiData::OnReactionRemoveEmojiData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
628 this->channelId = getId(dataReal["d"].value(), "channel_id");
629 this->messageId = getId(dataReal["d"].value(), "message_id");
630 this->guildId = getId(dataReal["d"].value(), "guild_id");
631 Value objectNew{};
632 if (dataReal["d"]["emoji"].get(objectNew) == ErrorCode::Success) {
633 this->emoji = EmojiData{ objectNew };
634 }
635 }
636
637 OnPresenceUpdateData::OnPresenceUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
638 this->presenceData = data.processJsonMessage<PresenceUpdateData>(std::move(dataReal), "d");
639 }
640
641 OnStageInstanceCreationData::OnStageInstanceCreationData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
642 this->stageInstance = data.processJsonMessage<StageInstance>(std::move(dataReal), "d");
643 GuildData guild{};
644 guild.id = this->stageInstance.guildId;
645 if (Guilds::getCache().contains(guild)) {
646 Guilds::getCache()[guild].stageInstances.emplace_back(this->stageInstance.id);
647 }
648 }
649
650 OnStageInstanceUpdateData::OnStageInstanceUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
651 this->stageInstance = data.processJsonMessage<StageInstance>(std::move(dataReal), "d");
652 }
653
654 OnStageInstanceDeletionData::OnStageInstanceDeletionData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
655 this->stageInstance = data.processJsonMessage<StageInstance>(std::move(dataReal), "d");
656 GuildData guild{};
657 guild.id = this->stageInstance.guildId;
658 if (Guilds::getCache().contains(guild)) {
659 for (uint64_t x = 0; x < Guilds::getCache()[guild].stageInstances.size(); ++x) {
660 if (Guilds::getCache()[guild].stageInstances[x] == this->stageInstance.id) {
661 Guilds::getCache()[guild].stageInstances.erase(Guilds::getCache()[guild].stageInstances.begin() + x);
662 }
663 }
664 }
665 }
666
667 OnTypingStartData::OnTypingStartData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
668 this->typingStartData = data.processJsonMessage<TypingStartData>(std::move(dataReal), "d");
669 }
670
671 OnUserUpdateData::OnUserUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
672 this->user = std::make_unique<UserData>(data.processJsonMessage<UserData>(std::move(dataReal), "d"));
673 if (Users::doWeCacheUsers()) {
674 Users::insertUser(*user);
675 }
676 }
677
678 OnVoiceStateUpdateData::OnVoiceStateUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal,
679 DiscordCoreInternal::WebSocketClient* sslShard) {
680 this->voiceStateData = data.processJsonMessage<VoiceStateData>(std::move(dataReal), "d");
681 sslShard->voiceConnectionData.sessionId = this->voiceStateData.sessionId;
682 if (sslShard->areWeCollectingData && !sslShard->stateUpdateCollected && !sslShard->serverUpdateCollected &&
683 this->voiceStateData.userId == sslShard->userId) {
684 sslShard->voiceConnectionData = DiscordCoreInternal::VoiceConnectionData{};
685 sslShard->voiceConnectionData.sessionId = this->voiceStateData.sessionId;
686 sslShard->stateUpdateCollected = true;
687 } else if (sslShard->areWeCollectingData && !sslShard->stateUpdateCollected) {
688 sslShard->voiceConnectionData.sessionId = this->voiceStateData.sessionId;
689 if (sslShard->voiceConnectionDataBuffersMap.contains(this->voiceStateData.guildId.operator size_t())) {
690 sslShard->voiceConnectionDataBuffersMap[this->voiceStateData.guildId.operator size_t()]->send(
691 sslShard->voiceConnectionData);
692 }
693 sslShard->serverUpdateCollected = false;
694 sslShard->stateUpdateCollected = false;
695 sslShard->areWeCollectingData = false;
696 }
697 GuildMembers::insertVoiceState(this->voiceStateData);
698 }
699
700 OnWebhookUpdateData::OnWebhookUpdateData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
701 this->channelId = getId(dataReal["d"].value(), "channel_id");
702 this->guildId = getId(dataReal["d"].value(), "guild_id");
703 }
704
705 OnAutoCompleteEntryData::OnAutoCompleteEntryData(DiscordCoreInternal::WebSocketMessage& data, Value dataReal) {
706 this->inputEvent = data.processJsonMessage<InputEventData>(std::move(dataReal), "d");
707 }
708
711 return this->onApplicationCommandPermissionsUpdateEvent.add(std::move(handler));
712 }
713
715 return this->onApplicationCommandPermissionsUpdateEvent.remove(token);
716 }
717
720 return this->onAutoModerationRuleCreationEvent.add(std::move(handler));
721 }
722
724 return this->onAutoModerationRuleCreationEvent.remove(token);
725 }
726
729 return this->onAutoModerationRuleUpdateEvent.add(std::move(handler));
730 }
731
733 return this->onAutoModerationRuleUpdateEvent.remove(token);
734 }
735
738 return this->onAutoModerationRuleDeletionEvent.add(std::move(handler));
739 }
740
742 return this->onAutoModerationRuleDeletionEvent.remove(token);
743 }
744
747 return this->onAutoModerationActionExecutionEvent.add(std::move(handler));
748 }
749
751 return this->onAutoModerationActionExecutionEvent.remove(token);
752 }
753
756 return this->onAutoCompleteEntryEvent.add(std::move(handler));
757 }
758
760 return this->onInputEventCreationEvent.remove(token);
761 }
762
765 return this->onInputEventCreationEvent.add(std::move(handler));
766 }
767
769 return this->onInputEventCreationEvent.remove(token);
770 }
771
774 return this->onChannelCreationEvent.add(std::move(handler));
775 }
776
778 onChannelCreationEvent.remove(token);
779 }
780
783 return this->onChannelUpdateEvent.add(std::move(handler));
784 }
785
787 onChannelUpdateEvent.remove(token);
788 }
789
792 return this->onChannelDeletionEvent.add(std::move(handler));
793 }
794
796 onChannelDeletionEvent.remove(token);
797 }
798
801 return this->onChannelPinsUpdateEvent.add(std::move(handler));
802 }
803
805 return this->onChannelPinsUpdateEvent.remove(token);
806 }
807
810 return this->onThreadCreationEvent.add(std::move(handler));
811 }
812
814 return this->onThreadCreationEvent.remove(token);
815 }
816
819 return this->onThreadUpdateEvent.add(std::move(handler));
820 }
821
823 return this->onThreadUpdateEvent.remove(token);
824 }
825
828 return this->onThreadDeletionEvent.add(std::move(handler));
829 }
830
832 return this->onThreadDeletionEvent.remove(token);
833 }
834
837 return this->onThreadListSyncEvent.add(std::move(handler));
838 }
839
841 return this->onThreadListSyncEvent.remove(token);
842 }
843
846 return this->onThreadMemberUpdateEvent.add(std::move(handler));
847 }
848
850 return this->onThreadMemberUpdateEvent.remove(token);
851 }
852
855 return this->onThreadMembersUpdateEvent.add(std::move(handler));
856 }
857
859 return this->onThreadMembersUpdateEvent.remove(token);
860 }
861
864 return this->onGuildCreationEvent.add(std::move(handler));
865 }
866
868 onGuildCreationEvent.remove(token);
869 }
870
873 return this->onGuildUpdateEvent.add(std::move(handler));
874 }
875
877 onGuildUpdateEvent.remove(token);
878 }
879
882 return this->onGuildDeletionEvent.add(std::move(handler));
883 }
884
886 onGuildDeletionEvent.remove(token);
887 }
888
891 return this->onGuildBanAddEvent.add(std::move(handler));
892 }
893
895 onGuildBanAddEvent.remove(token);
896 }
897
900 return this->onGuildBanRemoveEvent.add(std::move(handler));
901 }
902
904 onGuildBanRemoveEvent.remove(token);
905 }
906
909 return this->onGuildEmojisUpdateEvent.add(std::move(handler));
910 }
911
913 onGuildEmojisUpdateEvent.remove(token);
914 }
915
918 return this->onGuildStickersUpdateEvent.add(std::move(handler));
919 }
920
922 onGuildStickersUpdateEvent.remove(token);
923 }
924
927 return this->onGuildIntegrationsUpdateEvent.add(std::move(handler));
928 }
929
931 onGuildIntegrationsUpdateEvent.remove(token);
932 }
933
936 return this->onGuildMembersChunkEvent.add(std::move(handler));
937 }
938
940 onGuildMembersChunkEvent.remove(token);
941 }
942
945 return this->onGuildMemberAddEvent.add(std::move(handler));
946 }
947
949 onGuildMemberAddEvent.remove(token);
950 }
951
954 return this->onGuildMemberRemoveEvent.add(std::move(handler));
955 }
956
958 onGuildMemberRemoveEvent.remove(token);
959 }
960
963 return this->onGuildMemberUpdateEvent.add(std::move(handler));
964 }
965
967 onGuildMemberUpdateEvent.remove(token);
968 }
969
972 return this->onRoleCreationEvent.add(std::move(handler));
973 }
974
976 onRoleCreationEvent.remove(token);
977 }
978
981 return this->onRoleUpdateEvent.add(std::move(handler));
982 }
983
985 onRoleUpdateEvent.remove(token);
986 }
987
990 return this->onRoleDeletionEvent.add(std::move(handler));
991 }
992
994 onRoleDeletionEvent.remove(token);
995 }
996
999 return this->onGuildScheduledEventCreationEvent.add(std::move(handler));
1000 }
1001
1003 onGuildScheduledEventCreationEvent.remove(token);
1004 }
1005
1008 return this->onGuildScheduledEventUpdateEvent.add(std::move(handler));
1009 }
1010
1012 onGuildScheduledEventUpdateEvent.remove(token);
1013 }
1014
1017 return this->onGuildScheduledEventDeletionEvent.add(std::move(handler));
1018 }
1019
1021 onGuildScheduledEventDeletionEvent.remove(token);
1022 }
1023
1026 return this->onGuildScheduledEventUserAddEvent.add(std::move(handler));
1027 }
1028
1030 onGuildScheduledEventUserAddEvent.remove(token);
1031 }
1032
1035 return this->onGuildScheduledEventUserRemoveEvent.add(std::move(handler));
1036 }
1037
1039 onGuildScheduledEventUserRemoveEvent.remove(token);
1040 }
1041
1044 return this->onIntegrationCreationEvent.add(std::move(handler));
1045 }
1046
1048 onIntegrationCreationEvent.remove(token);
1049 }
1050
1053 return this->onIntegrationUpdateEvent.add(std::move(handler));
1054 }
1055
1057 onIntegrationUpdateEvent.remove(token);
1058 }
1059
1062 return this->onIntegrationDeletionEvent.add(std::move(handler));
1063 }
1064
1066 onIntegrationDeletionEvent.remove(token);
1067 }
1068
1071 return this->onInteractionCreationEvent.add(std::move(handler));
1072 }
1073
1075 onInteractionCreationEvent.remove(token);
1076 }
1077
1080 return this->onInviteCreationEvent.add(std::move(handler));
1081 }
1082
1084 onInviteCreationEvent.remove(token);
1085 }
1086
1089 return this->onInviteDeletionEvent.add(std::move(handler));
1090 }
1091
1093 onInviteDeletionEvent.remove(token);
1094 }
1095
1098 return this->onMessageCreationEvent.add(std::move(handler));
1099 }
1100
1102 onMessageCreationEvent.remove(token);
1103 }
1104
1107 return this->onMessageUpdateEvent.add(std::move(handler));
1108 }
1109
1111 onMessageUpdateEvent.remove(token);
1112 }
1113
1116 return this->onMessageDeletionEvent.add(std::move(handler));
1117 }
1118
1120 onMessageDeletionEvent.remove(token);
1121 }
1122
1125 return this->onMessageDeleteBulkEvent.add(std::move(handler));
1126 }
1127
1129 onMessageDeleteBulkEvent.remove(token);
1130 }
1131
1134 return this->onReactionAddEvent.add(std::move(handler));
1135 }
1136
1138 onReactionAddEvent.remove(token);
1139 }
1140
1143 return this->onReactionRemoveEvent.add(std::move(handler));
1144 }
1145
1147 onReactionRemoveEvent.remove(token);
1148 }
1149
1152 return this->onReactionRemoveAllEvent.add(std::move(handler));
1153 }
1154
1156 onReactionRemoveAllEvent.remove(token);
1157 }
1158
1161 return this->onReactionRemoveEmojiEvent.add(std::move(handler));
1162 }
1163
1165 onReactionRemoveEmojiEvent.remove(token);
1166 }
1167
1170 return this->onPresenceUpdateEvent.add(std::move(handler));
1171 }
1172
1174 onPresenceUpdateEvent.remove(token);
1175 }
1176
1179 return this->onStageInstanceCreationEvent.add(std::move(handler));
1180 }
1181
1183 onStageInstanceCreationEvent.remove(token);
1184 }
1185
1188 return this->onStageInstanceUpdateEvent.add(std::move(handler));
1189 }
1190
1192 onStageInstanceUpdateEvent.remove(token);
1193 }
1194
1197 return this->onStageInstanceDeletionEvent.add(std::move(handler));
1198 }
1199
1201 onStageInstanceDeletionEvent.remove(token);
1202 }
1203
1206 return this->onTypingStartEvent.add(std::move(handler));
1207 }
1208
1210 onTypingStartEvent.remove(token);
1211 }
1212
1215 return this->onUserUpdateEvent.add(std::move(handler));
1216 }
1217
1219 onUserUpdateEvent.remove(token);
1220 }
1221
1224 return this->onVoiceStateUpdateEvent.add(std::move(handler));
1225 }
1226
1228 onVoiceStateUpdateEvent.remove(token);
1229 }
1230
1233 return this->onVoiceServerUpdateEvent.add(std::move(handler));
1234 }
1235
1237 onVoiceServerUpdateEvent.remove(token);
1238 }
1239
1242 return this->onWebhookUpdateEvent.add(std::move(handler));
1243 }
1244
1246 onWebhookUpdateEvent.remove(token);
1247 }
1248
1249};
@ 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:52
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.