DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
Utilities.hpp
Go to the documentation of this file.
1/*
2 MIT License
3
4 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
5
6 Copyright 2022, 2023 Chris M. (RealTimeChris)
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in all
16 copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25*/
26/// Utilities.hpp - Header file for the utilities.
27/// Jun 28, 2022
28/// https://discordcoreapi.com
29/// \file Utilities.hpp
30#pragma once
31
38#include <coroutine>
39
40namespace discord_core_api {
41
42 /**
43 * \addtogroup foundation_entities
44 * @{
45 */
46
47 /// @brief Activity types.
48 enum class activity_type : uint8_t {
49 game = 0,///< Game.
50 streaming = 1,///< Streaming.
51 listening = 2,///< Listening.
52 watching = 3,///< Watching.
53 custom = 4,///< custom.
54 competing = 5///< competing.
55 };
56
57 struct time_stamps {
58 uint64_t start{};
59 uint64_t end{};
60 };
61
62 /// @brief Activity data.
64 unordered_set<jsonifier::string> excludedKeys{};
65 jsonifier::string details{};///< What the player is currently doing.
66 snowflake applicationId{};///< Application id for the game.
67 jsonifier::string state{};///< User's current party status, or text used for a custom status.
68 jsonifier::string name{};///< Name of the activity.
69 jsonifier::string url{};///< Stream url, is validated when type is 1.
70 time_stamps timestamps{};///< Timestamps object unix timestamps for start and / or end of the game.
71 uint64_t createdAt{};///< Unix timestamp(in milliseconds) of when the activity was added to the user's session.
72 activity_type type{};///< Activity's type.
73
74 activity_data() = default;
75
76 ~activity_data() = default;
77 };
78
79 /// @brief For connecting two bots to stream the vc contents between the two.
80 struct stream_info {
81 bool streamBotAudio{};///< Do we stream the audio coming from other bots?
82 jsonifier::string address{};///< The address to connect to.
83 stream_type type{};///< The type of streamer that this is. set one to client and one to server.
84 uint16_t port{};///< The port to connect to.
85 };
86
87 namespace discord_core_internal {
88
89 class sound_cloud_request_builder;
90 class you_tube_request_builder;
91 class websocket_client;
92 class base_socket_agent;
93 class sound_cloud_api;
94 class you_tube_api;
95
96 }// namespace discord_core_internal
97
98 struct on_voice_server_update_data;
99 struct on_voice_state_update_data;
100 struct file;
101
102 class discord_core_client;
103 class command_controller;
104 class voice_connection;
105 class guild_member_data;
106 class guild_members;
107 class channel_data;
108 class reactions;
109 class role_data;
110 class bot_user;
111
112 /**@}*/
113
114 /**
115 * \addtogroup utilities
116 * @{
117 */
118
119 template<typename return_type, bool timeOut = true> class co_routine;
120
121 /**@}*/
122
123 /**
124 * \addtogroup foundation_entities
125 * @{
126 */
127
128 enum class presence_update_state { online = 0, Do_Not_Disturb = 1, idle = 2, invisible = 3, offline = 4 };
129
130 /// @brief For updating a user's presence.
131 struct DiscordCoreAPI_Dll update_presence_data {
132 template<typename value_type> friend struct jsonifier::core;
133 jsonifier::vector<activity_data> activities{};///< A vector of activities.
134 unordered_set<jsonifier::string> excludedKeys{};
135 presence_update_state status{};///< current status.
136 int64_t since{};///< When was the activity started?
137 bool afk{};///< Are we afk.
138
139 inline update_presence_data() = default;
140 update_presence_data(presence_update_state updateState);
141
142 operator discord_core_internal::etf_serializer();
143
144 protected:
145 jsonifier::string statusReal{};
146 };
147
148 std::basic_ostream<char>& operator<<(std::basic_ostream<char>& outputSttream, jsonifier::string_view (*function)(void));
149
150 /// @brief Input event response types.
151 enum class input_event_response_type : uint8_t {
152 unset = 0,///< Unset.
153 Deferred_Response = 1,
154 Ephemeral_Deferred_Response = 2,///< Deferred ephemeral response.
155 Interaction_Response = 3,///< Interaction response.
156 Ephemeral_Interaction_Response = 4,///< Ephemeral interaction response.
157 Edit_Interaction_Response = 5,///< Interaction response edit.
158 Follow_Up_Message = 6,///< Follow-up message_data.
159 Ephemeral_Follow_Up_Message = 7,///< Ephemeral follow-up message_data.
160 Edit_Follow_Up_Message = 8,///< Follow-up message edit.
161 Application_Command_AutoComplete_Result = 9,///< Respond to an autocomplete interaction with suggested choices.
162 Modal_Interaction_Response = 10,///< Respond to an interaction with a popup modal.
163 };
164
165 /// @brief Gateway intents.
166 enum class gateway_intents : uint32_t {
167 guilds = 1 << 0,///< Intent for receipt of guild information.
168 Guild_Members = 1 << 1,///< Intent for receipt of guild members.
169 Guild_Bans = 1 << 2,///< Intent for receipt of guild bans.
170 Guild_Emojis = 1 << 3,///< Intent for receipt of guild emojis.
171 Guild_Integrations = 1 << 4,///< Intent for receipt of guild integrations.
172 Guild_Webhooks = 1 << 5,///< Intent for receipt of guild webhooks.
173 Guild_Invites = 1 << 6,///< Intent for receipt of guild invites.
174 Guild_VoiceStates = 1 << 7,///< Intent for receipt of guild voice states.
175 Guild_Presences = 1 << 8,///< Intent for receipt of guild presences.
176 Guild_Messages = 1 << 9,///< Intent for receipt of guild messages.
177 Guild_Message_Reactions = 1 << 10,///< Intent for receipt of guild message reactions.
178 Guild_Message_Typing = 1 << 11,///< Intent for receipt of guild message typing notifications.
179 Direct_Messages = 1 << 12,///< Intent for receipt of direct messages (dms).
180 Direct_Message_Reactions = 1 << 13,///< Intent for receipt of direct message reactions.
181 Direct_Message_Typing = 1 << 14,///< Intent for receipt of direct message typing notifications.
182 Message_Content = 1 << 15,///< Intent for receipt of message content.
183 Guild_Scheduled_Events = 1 << 16,///< Scheduled events.
184 Auto_Moderation_Configuration = 1 << 20,/// auto moderation configuration.
185 Auto_Moderation_Execution = 1 << 21,///< Auto moderation execution.
188 Auto_Moderation_Execution,///< Default intents (all non-privileged intents).
189 Privileged_Intents = Guild_Members | Guild_Presences | Message_Content,///< Privileged intents requiring id.
190 All_Intents = Default_Intents | Privileged_Intents///< Every single intent.
191 };
192
193 /// @brief Function data for repeated functions to be loaded.
195 std::function<void(discord_core_client*)> function{};///< The std::function char* to be loaded.
196 uint32_t intervalInMs{};///< The time interval at which to call the std::function.
197 bool repeated{};///< Whether or not the std::function is repeating.
198 int64_t dummyArg{};
199 };
200
201 /// @brief Represents which text format to use for websocket transfer.
202 enum class text_format : uint8_t {
203 etf = 0x00,///< Etf format.
204 json = 0x01///< Json format.
205 };
206
207 /// @brief Sharding options for the library.
209 uint32_t numberOfShardsForThisProcess{ 1 };///< The number of shards to launch on the current process.
210 uint32_t totalNumberOfShards{ 1 };///< The total number of shards that will be launched across all processes.
211 uint32_t startingShard{};///< The first shard to start on this process.
212 };
213
214 /// @brief Loggin options for the library.
216 std::ostream* outputStream{ &std::cout };
217 std::ostream* errorStream{ &std::cerr };
218 bool logWebSocketSuccessMessages{};///< Do we log the websocket success messages to std::cout?
219 bool logWebSocketErrorMessages{};///< Do we log the websocket error messages to std::cout?
220 bool logGeneralSuccessMessages{};///< Do we log general success messages to std::cout?
221 bool logGeneralErrorMessages{};///< Do we log general error messages to std::cout?
222 bool logHttpsSuccessMessages{};///< Do we log https response success messages to std::cout?
223 bool logHttpsErrorMessages{};///< Do we log https response error messages to std::cout?
224 };
225
226 /// @brief For selecting the caching style of the library.
228 bool cacheGuildMembers{ true };///< Do we cache guild_members?
229 bool cacheVoiceStates{ true };///< Do we cache voices states?
230 bool cacheChannels{ true };///< Do we cache channels?
231 bool cacheGuilds{ true };///< Do we cache guilds?
232 bool cacheRoles{ true };///< Do we cache roles?
233 bool cacheUsers{ true };///< Do we cache users?
234 };
235
236 /// @brief Configuration data for the library's main class, discord_core_client.
238 update_presence_data presenceData{ presence_update_state::online };///< Presence data to initialize your bot with.
239 jsonifier::vector<repeated_function_data> functionsToExecute{};///< Functions to execute after a timer, or on a repetition.
240 gateway_intents intents{ gateway_intents::All_Intents };///< The gateway intents to be used for this instance.
241 text_format textFormat{ text_format::etf };///< Use etf or json format for websocket transfer?
242 jsonifier::string connectionAddress{};///< A potentially alternative connection address for the websocket.
243 sharding_options shardOptions{};///< Options for the sharding of your bot.
244 jsonifier::string botToken{};///< Your bot's token.
245 logging_options logOptions{};///< Options for the output/logging of the library.
246 cache_options cacheOptions{};///< Options for the cache of the library.
247 uint16_t connectionPort{};///< A potentially alternative connection port for the websocket.
248 };
249
250 struct json_string_value {
252 jsonifier::raw_json_data value{};
253 };
254
255 class DiscordCoreAPI_Dll config_manager {
256 public:
257 config_manager() = default;
258
259 explicit config_manager(const discord_core_client_config&);
260
261 bool doWePrintWebSocketSuccessMessages() const;
262
263 bool doWePrintWebSocketErrorMessages() const;
264
265 bool doWePrintHttpsSuccessMessages() const;
266
267 bool doWePrintHttpsErrorMessages() const;
268
269 bool doWePrintGeneralSuccessMessages() const;
270
271 bool doWePrintGeneralErrorMessages() const;
272
273 bool doWeCacheGuildMembers() const;
274
275 bool doWeCacheVoiceStates() const;
276
277 bool doWeCacheChannels() const;
278
279 bool doWeCacheUsers() const;
280
281 bool doWeCacheGuilds() const;
282
283 bool doWeCacheRoles() const;
284
285 update_presence_data getPresenceData() const;
286
287 jsonifier::string getBotToken() const;
288
289 uint64_t getTotalShardCount() const;
290
291 std::ostream* getOutputStream() const;
292
293 std::ostream* getErrorStream() const;
294
295 uint64_t getStartingShard() const;
296
297 uint64_t getShardCountForThisProcess() const;
298
299 jsonifier::string getConnectionAddress() const;
300
301 void setConnectionAddress(jsonifier::string_view connectionAddressNew);
302
303 uint16_t getConnectionPort() const;
304
305 void setConnectionPort(const uint16_t connectionPortNew);
306
307 jsonifier::vector<repeated_function_data> getFunctionsToExecute() const;
308
309 text_format getTextFormat() const;
310
311 gateway_intents getGatewayIntents();
312
313 protected:
314 discord_core_client_config config{};
315 };
316
317 /// @brief Color constants for use in the embed_data color values.
318 namespace colors {
319 static constexpr jsonifier::string_view white{ "ffffff" },///< White.
320 discord_white{ "fffffe" },///< Discord white.
321 light_gray{ "c0_c0_c0" },///< Light gray.
322 gray{ "808080" },///< Gray.
323 dark_gray{ "404040" },///< Dark gray.
324 black{ "000000" },///< Black.
325 discord_black{ "000001" },///< Discord black.
326 red{ "ff0000" },///< Red.
327 pink{ "ffafaf" },///< Pink.
328 orange{ "ffc800" },///< Orange.
329 yellow{ "ffff00" },///< Yellow.
330 green{ "00FF00" },///< Green.
331 magenta{ "ff00_ff" },///< Magenta.
332 cyan{ "00FFFF" },///< cyan.
333 blue{ "0000FF" },///< Blue.
334 light_sea_green{ "1ABC9C" },///< Light sea green.
335 medium_sea_green{ "2ECC71" },///< Medium sea green.
336 summer_sky{ "3498DB" },///< Summer skye.
337 deep_lilac{ "9B59B6" },///< Deep lilac.
338 ruby{ "e91_e63" },///< Ruby.
339 moon_yellow{ "f1_c40_f" },///< Moon yellow.
340 tahiti_gold{ "e67_e22" },///< Tahiti gold.
341 cinnabar{ "e74_c3_c" },///< cinnabar.
342 submarine{ "95A5A6" },///< Submarine.
343 blue_aquamarine{ "607D8B" },///< Blue aquamarine.
344 deep_sea{ "11806A" },///< Deep sea.
345 sea_green{ "1F8B4C" },///< Sea green.
346 endeavour{ "206694" },///< Endeavor.
347 vivid_violet{ "71368A" },///< Vivid violet.
348 jazzberry_jam{ "ad1457" },///< Jazzberry jam.
349 dark_goldenrod{ "c27_c0_e" },///< Dark goldenrod.
350 rust{ "a84300" },///< Rust.
351 brown{ "992D22" },///< Brown.
352 gray_chateau{ "979C9F" },///< Gray chateau.
353 bismark{ "546E7A" },///< Bismark.
354 sti_blue{ "0E4BEF" },///< Sti blue.
355 wrx_blue{ "00247D" },///< Wrx blue.
356 ralli_art_crimson{ "e60012" },///< Ralliart crimson.
357 lime{ "00FF00" },///< Lime.
358 forest_green{ "228B22" },///< Forest green.
359 cadmium_green{ "097969" },///< cadmium green.
360 aquamarine{ "7FFFD4" },///< Aquamarine.
361 blue_green{ "088F8F" },///< Blue green.
362 raspberry{ "e30_b5_c" },///< Raspberry.
363 scarlet_red{ "ff2400" };///< Scarlet red.
364 };
365
366 /**@}*/
367
368 /**
369 * \addtogroup voice_connection
370 * @{
371 */
372
373 /// @brief Audio frame types.
374 enum class audio_frame_type : uint8_t {
375 unset = 0,///< Unset.
376 raw_pcm = 1,///< Raw pcm.
377 encoded = 2,///< Encoded audio data.
378 };
379
380 /// @brief Represents a single frame of audio data.
381 struct DiscordCoreAPI_Dll audio_frame_data {
382 audio_frame_type type{ audio_frame_type::unset };///< The type of audio frame.
383 jsonifier::vector<uint8_t> data{};///< The audio data.
384 int64_t currentSize{ -5 };///< The current size of the allocated memory.
385
386 audio_frame_data() = default;
387
389
390 audio_frame_data& operator+=(jsonifier::string_view_base<uint8_t>);
391
392 audio_frame_data& operator+=(jsonifier::vector<uint8_t>);
393
394 inline bool operator==(const audio_frame_data& rhs) const {
395 return currentSize == rhs.currentSize && data == rhs.data;
396 }
397
398 void clearData();
399 };
400
401 /// for connecting to a voice-channel. "streamInfo" is used when a SOCKET is created to connect this bot to another bot, for transmitting audio back and forth.
402 /// @brief For connecting to a voice-channel. "streamInfo" is used when a SOCKET is created to connect this bot to another bot, for transmitting audio back and forth.
404 stream_info streamInfo{};///< The info for the stream-SOCKET, if applicable.
405 int32_t currentShard{};///< The current websocket shard, if applicable.
406 snowflake channelId{};///< The channel id to connect to.
407 snowflake guildId{};///< The guild id to connect to.
408 snowflake userId{};///< This bot's user id.
409 bool selfDeaf{};///< Self-deafen the bot?
410 bool selfMute{};///< Self-mute the bot?
411 };
412
413 /**@}*/
414
415 /**
416 * \addtogroup utilities
417 * @{
418 */
419
420 template<typename return_type> inline return_type fromString(jsonifier::string_view string, std::ios_base& (*type)( std::ios_base& )) {
421 return_type value{};
422 std::istringstream stream(std::string{ string });
423 stream >> type, stream >> value;
424 return value;
425 }
426
427 template<typename return_type> inline jsonifier::string toHex(return_type inputValue) {
428 std::stringstream stream{};
429 stream << std::setfill('0') << std::setw(sizeof(return_type) * 2) << std::hex << inputValue;
430 return jsonifier::string{ stream.str() };
431 }
432
433 class rgbcolor_value {
434 public:
435 uint8_t green{};
436 uint8_t blue{};
437 uint8_t red{};
438 };
439
440 using hex_color_value = jsonifier::string;
441
442 class DiscordCoreAPI_Dll color_value {
443 public:
444 template<typename value_type> friend struct jsonifier::core;
445
446 color_value(jsonifier::string_view hexColorValue);
447
448 rgbcolor_value getRgbColorValue();
449
450 hex_color_value getHexColorValue();
451
452 color_value(uint32_t colorValue);
453
454 uint32_t getIntColorValue();
455
456 protected:
457 uint32_t color{};
458 };
459
460 enum class hash_type { User_Avatar = 0, Channel_Icon = 1, GuildMember_Avatar = 2, Guild_Icon = 3, Guild_Splash = 4, Guild_Banner = 5, Guild_Discovery = 6 };
461
462 class DiscordCoreAPI_Dll icon_hash {
463 public:
464 icon_hash() = default;
465
466 icon_hash& operator=(jsonifier::string_view string);
467
468 icon_hash(jsonifier::string_view string);
469
470 bool operator==(jsonifier::string_view rhs) const;
471
472 bool operator==(const icon_hash& rhs) const;
473
474 friend jsonifier::string operator+(const icon_hash& lhs, jsonifier::string rhs);
475
476 operator jsonifier::string() const;
477
478 protected:
479 uint64_t highBits{};
480 uint64_t lowBits{};
481 };
482
483 /**@}*/
484
485 /**
486 * \addtogroup foundation_entities
487 * @{
488 */
489
490 /// @brief Permission values, for a given channel, by role_data or guild_member_data.
491 enum class permission : uint64_t {
492 Create_Instant_Invite = 0x0000000000000001,///< Allows creation of instant invites.
493 Kick_Members = 0x0000000000000002,///< Allows kicking members.
494 Ban_Members = 0x0000000000000004,///< Allows banning members.
495 administrator = 0x0000000000000008,///< Allows all permissions and bypasses channel permission overwrites.
496 Manage_Channels = 0x0000000000000010,///< Allows management and editing of channels.
497 Manage_Guild = 0x0000000000000020,///< Allows management and editing of the guild.
498 Add_Reactions = 0x0000000000000040,///< Allows for the addition of reactions to messages.
499 View_Audit_Log = 0x0000000000000080,///< Allows for viewing of audit logs.
500 Priority_Speaker = 0x0000000000000100,///< Allows for using priority speaker in a voice channel.
501 stream = 0x0000000000000200,///< Allows the user to go live.
502 View_Channel = 0x0000000000000400,///< Allows guild members to view a channel, which includes reading messages in text channels.
503 Send_Messages = 0x0000000000000800,///< Allows for sending messages in a channel and creating threads in a forum.
504 Send_TTS_Messages = 0x0000000000001000,///< Allows for sending of /tts messages.
505 Manage_Messages = 0x0000000000002000,///< Allows for deletion of other users messages.
506 Embed_Links = 0x0000000000004000,///< Links sent by users with this permission will be auto-embedded.
507 Attach_Files = 0x0000000000008000,///< Allows for uploading images and files.
508 Read_Message_History = 0x0000000000010000,///< Allows for reading of message history.
509 Mention_Everyone = 0x0000000000020000,///< Allows for using the at-everyone tag to notify all users in a channel.
510 Use_External_Emojis = 0x0000000000040000,///< Allows the usage of custom emojis from other servers.
511 View_Guild_Insights = 0x0000000000080000,///< Allows for viewing guild insights.
512 connect = 0x0000000000100000,///< Allows for joining of a voice channel.
513 speak = 0x0000000000200000,///< Allows for speaking in a voice channel.
514 Mute_Members = 0x0000000000400000,///< Allows for muting members in a voice channel.
515 Deafen_Members = 0x0000000000800000,///< Allows for deafening of members in a voice channel.
516 Move_Members = 0x0000000001000000,///< Allows for moving of members between voice channels.
517 Use_VAD = 0x0000000002000000,///< Allows for using voice-activity-detection in a voice channel.
518 Change_Nickname = 0x0000000004000000,///< Allows for modification of own nickname.
519 Manage_Nicknames = 0x0000000008000000,///< Allows for modification of other users nicknames.
520 Manage_Roles = 0x0000000010000000,///< Allows management and editing of roles.
521 Manage_Webhooks = 0x0000000020000000,///< Allows management and editing of webhooks.
522 Manage_Guild_Expressions = 0x0000000040000000,///< Allows management and editing of emojis, stickers, and soundboard sounds.
523 Use_Application_Commands = 0x0000000080000000,///< Allows members to use application commands, including slash commands and context menu.
524 Request_to_Speak = 0x0000000100000000,///< Allows for requesting to speak in stage channels. (this permission is under active development).
525 Manage_Events = 0x0000000200000000,///< Allows for creating, editing, and deleting scheduled events.
526 Manage_Threads = 0x0000000400000000,///< Allows for deleting and archiving threads, and viewing all protected threads.
527 Create_Public_Threads = 0x0000000800000000,///< Allows for creating public and announcement threads.
528 Create_Private_Threads = 0x0000001000000000,///< Allows for creating protected threads.
529 Use_External_Stickers = 0x0000002000000000,///< Allows the usage of custom stickers from other servers.
530 Send_Messages_in_Threads = 0x0000004000000000,///< Allows for sending messages in threads.
531 Use_Embedded_Activities = 0x0000008000000000,///< Allows for using activities (applications with the embedded flag) in a voice channel.
532 Moderate_Members = 0x0000010000000000,///< Allows for timing out users to prevent them from sending or reacting to messages in chat.
533 View_Creator_Monetization_Analytics = 0x0000020000000000,///< Allows for viewing role subscription insights.
534 Use_Soundboard = 0x0000040000000000,///< Allows for using soundboard in a voice channel.
535 Use_External_Sounds = 0x0000200000000000,///< Allows the usage of custom soundboard sounds from other servers.
536 Send_Voice_Messages = 0x0000400000000000,///< Allows sending voice messages.
537 };
538
539 /// @brief Permissions_base class, for representing and manipulating permission values.
540 template<typename value_type> class permissions_base {
541 public:
542 friend class jsonifier_internal::parser;
543
544 /// @brief Returns a string containing all of a given user's permissions_base for a given channel.
545 /// @param guildMember the guild_member_data who's permissions_base to analyze.
546 /// @param channel the channel_data withint which to check for permissions_base.
547 /// @return jsonifier::string a string containing the final permission's value for a given channel.
548 inline static jsonifier::string getCurrentChannelPermissions(const guild_member_data& guildMember, const channel_data& channel) {
549 return computePermissions(guildMember, channel);
550 }
551
552 /// @brief Checks for a given permission in a chosen channel_data, for a specific user_data.
553 /// @param guildMember the guild_member_data who to check the permissions_base of.
554 /// @param channel the channel_data within which to check for the permission's presence.
555 /// @param permission a permission to check the current channel_data for.
556 /// @return bool a bool suggesting the presence of the chosen permission.
557 inline bool checkForPermission(const guild_member_data& guildMember, const channel_data& channel, permission permission) {
558 if ((jsonifier::strToUint64(computePermissions(guildMember, channel).data()) & static_cast<uint64_t>(permission)) == static_cast<uint64_t>(permission)) {
559 return true;
560 } else {
561 return false;
562 }
563 }
564
565 /// @brief Returns a string containing the currently held permissions_base in a given guild.
566 /// @param guildMember the guild_member_data who's permissions_base are to be evaluated.
567 /// @return jsonifier::string a string containing the current permissions_base.
568 inline static jsonifier::string getCurrentGuildPermissions(const guild_member_data& guildMember) {
569 permissions_base setValue(computeBasePermissions(guildMember));
570 return static_cast<value_type*>(setValue);
571 }
572
573 /// @brief Removes one or more permissions_base from the current permissions_base value.
574 /// @param permissionsToRemove a vector containing the permissions_base you wish to remove.
575 inline void removePermissions(const jsonifier::vector<permission>& permissionsToRemove) {
576 uint64_t permissionsInteger = *static_cast<value_type*>(this);
577 for (auto valueNew: permissionsToRemove) {
578 permissionsInteger &= ~static_cast<uint64_t>(valueNew);
579 }
580 std::stringstream sstream{};
581 sstream << permissionsInteger;
582 *static_cast<value_type*>(this) = jsonifier::string{ sstream.str() };
583 }
584
585 /// @brief Adds one or more permissions_base to the current permissions_base value.
586 /// @param permissionsToAdd a vector containing the permissions_base you wish to add.
587 inline void addPermissions(const jsonifier::vector<permission>& permissionsToAdd) {
588 uint64_t permissionsInteger = *static_cast<value_type*>(this);
589 for (auto valueNew: permissionsToAdd) {
590 permissionsInteger |= static_cast<uint64_t>(valueNew);
591 }
592 std::stringstream sstream{};
593 sstream << permissionsInteger;
594 *static_cast<value_type*>(this) = jsonifier::string{ sstream.str() };
595 }
596
597 /// @brief Displays the currently present permissions_base in a string, and returns A vector with each of them stored in string format.
598 /// @return jsonifier::vector a vector full of strings of the permissions_base that are in the input jsonifier::string's value.
599 inline jsonifier::vector<jsonifier::string> displayPermissions() {
600 jsonifier::vector<jsonifier::string> returnVector{};
601 uint64_t permissionsInteger = *static_cast<value_type*>(this);
602 if (permissionsInteger & (1ll << 3)) {
603 for (int64_t x = 0; x < 46; ++x) {
604 permissionsInteger |= 1ll << x;
605 }
606 }
607 if (permissionsInteger & static_cast<uint64_t>(permission::Create_Instant_Invite)) {
608 returnVector.emplace_back("create instant invite");
609 }
610 if (permissionsInteger & static_cast<uint64_t>(permission::Kick_Members)) {
611 returnVector.emplace_back("kick members");
612 }
613 if (permissionsInteger & static_cast<uint64_t>(permission::Ban_Members)) {
614 returnVector.emplace_back("ban members");
615 }
616 if (permissionsInteger & static_cast<uint64_t>(permission::administrator)) {
617 returnVector.emplace_back("administrator");
618 }
619 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Channels)) {
620 returnVector.emplace_back("manage channels");
621 }
622 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Guild)) {
623 returnVector.emplace_back("manage guild");
624 }
625 if (permissionsInteger & static_cast<uint64_t>(permission::Add_Reactions)) {
626 returnVector.emplace_back("add reactions");
627 }
628 if (permissionsInteger & static_cast<uint64_t>(permission::View_Audit_Log)) {
629 returnVector.emplace_back("view audit log");
630 }
631 if (permissionsInteger & static_cast<uint64_t>(permission::Priority_Speaker)) {
632 returnVector.emplace_back("priority speaker");
633 }
634 if (permissionsInteger & static_cast<uint64_t>(permission::stream)) {
635 returnVector.emplace_back("stream");
636 }
637 if (permissionsInteger & static_cast<uint64_t>(permission::View_Channel)) {
638 returnVector.emplace_back("view channel");
639 }
640 if (permissionsInteger & static_cast<uint64_t>(permission::Send_Messages)) {
641 returnVector.emplace_back("send messages");
642 }
643 if (permissionsInteger & static_cast<uint64_t>(permission::Send_TTS_Messages)) {
644 returnVector.emplace_back("send tts messages");
645 }
646 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Messages)) {
647 returnVector.emplace_back("manage messages");
648 }
649 if (permissionsInteger & static_cast<uint64_t>(permission::Embed_Links)) {
650 returnVector.emplace_back("embed links");
651 }
652 if (permissionsInteger & static_cast<uint64_t>(permission::Attach_Files)) {
653 returnVector.emplace_back("attach files");
654 }
655 if (permissionsInteger & static_cast<uint64_t>(permission::Read_Message_History)) {
656 returnVector.emplace_back("read message history");
657 }
658 if (permissionsInteger & static_cast<uint64_t>(permission::Mention_Everyone)) {
659 returnVector.emplace_back("mention everyone");
660 }
661 if (permissionsInteger & static_cast<uint64_t>(permission::Use_External_Emojis)) {
662 returnVector.emplace_back("use external emoji");
663 }
664 if (permissionsInteger & static_cast<uint64_t>(permission::View_Guild_Insights)) {
665 returnVector.emplace_back("view guild insights");
666 }
667 if (permissionsInteger & static_cast<uint64_t>(permission::connect)) {
668 returnVector.emplace_back("connect");
669 }
670 if (permissionsInteger & static_cast<uint64_t>(permission::speak)) {
671 returnVector.emplace_back("speak");
672 }
673 if (permissionsInteger & static_cast<uint64_t>(permission::Mute_Members)) {
674 returnVector.emplace_back("mute members");
675 }
676 if (permissionsInteger & static_cast<uint64_t>(permission::Deafen_Members)) {
677 returnVector.emplace_back("deafen members");
678 }
679 if (permissionsInteger & static_cast<uint64_t>(permission::Move_Members)) {
680 returnVector.emplace_back("move members");
681 }
682 if (permissionsInteger & static_cast<uint64_t>(permission::Use_VAD)) {
683 returnVector.emplace_back("use vad");
684 }
685 if (permissionsInteger & static_cast<uint64_t>(permission::Change_Nickname)) {
686 returnVector.emplace_back("change nickname");
687 }
688 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Nicknames)) {
689 returnVector.emplace_back("manage nicknames");
690 }
691 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Roles)) {
692 returnVector.emplace_back("manage roles");
693 }
694 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Webhooks)) {
695 returnVector.emplace_back("manage webhooks");
696 }
697 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Guild_Expressions)) {
698 returnVector.emplace_back("manage emojis and stickers");
699 }
700 if (permissionsInteger & static_cast<uint64_t>(permission::Use_Application_Commands)) {
701 returnVector.emplace_back("use application commands");
702 }
703 if (permissionsInteger & static_cast<uint64_t>(permission::Request_to_Speak)) {
704 returnVector.emplace_back("request to speak");
705 }
706 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Events)) {
707 returnVector.emplace_back("manage events");
708 }
709 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Threads)) {
710 returnVector.emplace_back("manage threads");
711 }
712 if (permissionsInteger & static_cast<uint64_t>(permission::Create_Public_Threads)) {
713 returnVector.emplace_back("create public threads");
714 }
715 if (permissionsInteger & static_cast<uint64_t>(permission::Create_Private_Threads)) {
716 returnVector.emplace_back("create private threads");
717 }
718 if (permissionsInteger & static_cast<uint64_t>(permission::Use_External_Stickers)) {
719 returnVector.emplace_back("use external stickers");
720 }
721 if (permissionsInteger & static_cast<uint64_t>(permission::Send_Messages_in_Threads)) {
722 returnVector.emplace_back("send messages in threads");
723 }
724 if (permissionsInteger & static_cast<uint64_t>(permission::Use_Embedded_Activities)) {
725 returnVector.emplace_back("start embedded activities");
726 }
727 if (permissionsInteger & static_cast<uint64_t>(permission::Moderate_Members)) {
728 returnVector.emplace_back("moderate members");
729 }
730 if (permissionsInteger & static_cast<uint64_t>(permission::View_Creator_Monetization_Analytics)) {
731 returnVector.emplace_back("view creator monetization analytics");
732 }
733 if (permissionsInteger & static_cast<uint64_t>(permission::Use_Soundboard)) {
734 returnVector.emplace_back("use soundboard");
735 }
736 if (permissionsInteger & static_cast<uint64_t>(permission::Use_External_Sounds)) {
737 returnVector.emplace_back("use external sounds");
738 }
739 if (permissionsInteger & static_cast<uint64_t>(permission::Send_Voice_Messages)) {
740 returnVector.emplace_back("send voice messages");
741 }
742 return returnVector;
743 }
744
745 /// @brief Returns a string containing the currently held permissions_base.
746 /// @return jsonifier::string a string containing the current permissions_base.
747 inline jsonifier::string getCurrentPermissionString() {
748 jsonifier::string returnString = *static_cast<value_type*>(this);
749 return returnString;
750 }
751
752 /// @brief Returns a string containing all of the possible permissions_base.
753 /// @return jsonifier::string a string containing all of the possible permissions_base.
754 inline static jsonifier::string getAllPermissions() {
755 uint64_t allPerms{};
756 for (int64_t x = 0; x < 46; ++x) {
757 allPerms |= 1ll << x;
758 }
759 std::stringstream stream{};
760 stream << allPerms;
761 return jsonifier::string{ stream.str() };
762 }
763
764 protected:
765 inline permissions_base() = default;
766
767 DiscordCoreAPI_Dll static jsonifier::string computeOverwrites(jsonifier::string_view basePermissions, const guild_member_data& guildMember, const channel_data& channel);
768
769 inline static jsonifier::string computePermissions(const guild_member_data& guildMember, const channel_data& channel) {
770 jsonifier::string permissions = computeBasePermissions(guildMember);
771 permissions = computeOverwrites(permissions, guildMember, channel);
772 return permissions;
773 }
774
775 DiscordCoreAPI_Dll static jsonifier::string computeBasePermissions(const guild_member_data& guildMember);
776 };
777
778 class permissions_parse : public permissions_base<permissions_parse>, public jsonifier::string {
779 public:
780 template<typename value_type> friend class permissions_base;
781
782 inline permissions_parse() = default;
783
784 inline permissions_parse& operator=(jsonifier::string_view valueNew) {
785 resize(valueNew.size());
786 std::memcpy(data(), valueNew.data(), size());
787 return *this;
788 }
789
790 inline permissions_parse(jsonifier::string_view valueNew) {
791 *this = valueNew;
792 }
793
794 inline permissions_parse& operator=(uint64_t valueNew) {
795 *this = jsonifier::toString(valueNew);
796 return *this;
797 }
798
799 inline permissions_parse(uint64_t valueNew) {
800 *this = valueNew;
801 }
802
803 inline permissions_parse substr(uint64_t offset, uint64_t count) const {
804 return substr(offset, count);
805 }
806
807 inline uint64_t size() const {
808 return jsonifier::string::size();
809 }
810
811 inline char* data() const {
812 return jsonifier::string::data();
813 }
814
815 inline operator uint64_t() const {
816 return jsonifier::strToUint64(data());
817 }
818 };
819
820 class permissions : public permissions_base<permissions> {
821 public:
822 template<typename value_type> friend class permissions_base;
823
824 inline permissions() = default;
825
826 inline permissions& operator=(const permissions_parse& other) {
827 value = other.operator uint64_t();
828 return *this;
829 }
830
831 inline permissions(const permissions_parse& other) {
832 *this = other;
833 }
834
835 inline permissions& operator=(jsonifier::string_view valueNew) {
836 value = jsonifier::strToUint64(valueNew.data());
837 return *this;
838 }
839
840 inline permissions(jsonifier::string_view valueNew) {
841 *this = valueNew;
842 }
843
844 inline permissions& operator=(jsonifier::string&& valueNew) {
845 value = jsonifier::strToUint64(valueNew.data());
846 return *this;
847 }
848
849 inline permissions(jsonifier::string&& valueNew) {
850 *this = std::move(valueNew);
851 }
852
853 inline permissions& operator=(uint64_t valueNew) {
854 value = valueNew;
855 return *this;
856 }
857
858 inline permissions(uint64_t valueNew) {
859 *this = valueNew;
860 }
861
862 inline operator uint64_t() const {
863 return value;
864 }
865
866 inline operator jsonifier::string() const {
867 return jsonifier::toString(value);
868 }
869
870 protected:
871 uint64_t value{};
872 };
873
874 DiscordCoreAPI_Dll jsonifier::string constructMultiPartData(jsonifier::string_view data, const jsonifier::vector<file>& files);
875
876 DiscordCoreAPI_Dll jsonifier::string convertToLowerCase(jsonifier::string_view stringToConvert);
877
878 DiscordCoreAPI_Dll jsonifier::string base64Encode(jsonifier::string_view, bool = false);
879
880 DiscordCoreAPI_Dll jsonifier::string loadFileContents(jsonifier::string_view filePath);
881
882 DiscordCoreAPI_Dll jsonifier::string utf8MakeValid(jsonifier::string_view inputString);
883
884 DiscordCoreAPI_Dll jsonifier::string urlEncode(jsonifier::string_view inputString);
885
886 DiscordCoreAPI_Dll void spinLock(uint64_t timeInNsToSpinLockFor);
887
888 DiscordCoreAPI_Dll jsonifier::string generateBase64EncodedKey();
889
890 DiscordCoreAPI_Dll bool nanoSleep(int64_t ns);
891
892 /// @brief Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
893 /// @return jsonifier::string a string containing the current date-time stamp.
894 DiscordCoreAPI_Dll jsonifier::string getTimeAndDate();
895
896 /**@}*/
897
898 /**
899 * \addtogroup utilities
900 * @{
901 */
902 template<typename return_type, bool timeOut = true> class new_thread_awaiter;
903
904 /// @brief An awaitable that can be used to launch the co_routine onto a new thread - as well as return the handle for stoppping its execution.
905 /// @tparam return_type the type of value returned by the containing co_routine.
906 /// @tparam timeOut whether or not to time out the co_routine's execution after a period of time.
907 /// @return new_thread_awaiter<return_type, timeOut> a new_thread_awaiter for suspendint the current co_routine's execution.
908 template<typename return_type, bool timeOut = true> inline auto newThreadAwaitable() {
910 }
911
912 /**@}*/
913};
discord_core_client - the main class for this library.
Data structure representing a single guild_member_data.
An interface class for the guild_data related discord endpoints.
An awaitable that can be used to launch the co_routine onto a new thread - as well as return the hand...
Definition: CoRoutine.hpp:466
Permissions_base class, for representing and manipulating permission values.
Definition: Utilities.hpp:540
bool checkForPermission(const guild_member_data &guildMember, const channel_data &channel, permission permission)
Checks for a given permission in a chosen channel_data, for a specific user_data.
Definition: Utilities.hpp:557
static jsonifier::string getCurrentGuildPermissions(const guild_member_data &guildMember)
Returns a string containing the currently held permissions_base in a given guild.
Definition: Utilities.hpp:568
static jsonifier::string getCurrentChannelPermissions(const guild_member_data &guildMember, const channel_data &channel)
Returns a string containing all of a given user's permissions_base for a given channel.
Definition: Utilities.hpp:548
void removePermissions(const jsonifier::vector< permission > &permissionsToRemove)
Removes one or more permissions_base from the current permissions_base value.
Definition: Utilities.hpp:575
jsonifier::vector< jsonifier::string > displayPermissions()
Displays the currently present permissions_base in a string, and returns A vector with each of them s...
Definition: Utilities.hpp:599
void addPermissions(const jsonifier::vector< permission > &permissionsToAdd)
Adds one or more permissions_base to the current permissions_base value.
Definition: Utilities.hpp:587
static jsonifier::string getAllPermissions()
Returns a string containing all of the possible permissions_base.
Definition: Utilities.hpp:754
jsonifier::string getCurrentPermissionString()
Returns a string containing the currently held permissions_base.
Definition: Utilities.hpp:747
A class representing a snowflake identifier with various operations.
Definition: Base.hpp:680
json_type
Enumeration for different json value types.
Definition: Etf.hpp:440
input_event_response_type
Input event response types.
Definition: Utilities.hpp:151
text_format
Represents which text format to use for websocket transfer.
Definition: Utilities.hpp:202
activity_type
Activity types.
Definition: Utilities.hpp:48
gateway_intents
Gateway intents.
Definition: Utilities.hpp:166
permission
Permission values, for a given channel, by role_data or guild_member_data.
Definition: Utilities.hpp:491
DiscordCoreAPI_Dll jsonifier::string getTimeAndDate()
Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
Definition: Utilities.cpp:632
@ Ephemeral_Interaction_Response
Ephemeral interaction response.
@ Ephemeral_Deferred_Response
Deferred ephemeral response.
@ Modal_Interaction_Response
Respond to an interaction with a popup modal.
@ Edit_Interaction_Response
Interaction response edit.
@ Application_Command_AutoComplete_Result
Respond to an autocomplete interaction with suggested choices.
@ Edit_Follow_Up_Message
Follow-up message edit.
@ Ephemeral_Follow_Up_Message
Ephemeral follow-up message_data.
@ Follow_Up_Message
Follow-up message_data.
@ Guild_Scheduled_Events
Scheduled events.
@ Privileged_Intents
Privileged intents requiring id.
@ Guild_Integrations
Intent for receipt of guild integrations.
@ Guild_Message_Typing
Intent for receipt of guild message typing notifications.
@ Message_Content
Intent for receipt of message content.
@ All_Intents
Every single intent.
@ Default_Intents
Default intents (all non-privileged intents).
@ Guild_Bans
Intent for receipt of guild bans.
@ Guild_Message_Reactions
Intent for receipt of guild message reactions.
@ Direct_Message_Typing
Intent for receipt of direct message typing notifications.
@ Guild_Invites
Intent for receipt of guild invites.
@ Guild_Emojis
Intent for receipt of guild emojis.
@ Guild_Presences
Intent for receipt of guild presences.
@ Guild_Webhooks
Intent for receipt of guild webhooks.
@ Guild_VoiceStates
Intent for receipt of guild voice states.
@ Direct_Message_Reactions
Intent for receipt of direct message reactions.
@ Guild_Messages
Intent for receipt of guild messages.
@ Guild_Members
Intent for receipt of guild members.
@ Auto_Moderation_Execution
auto moderation configuration.
@ Direct_Messages
Intent for receipt of direct messages (dms).
@ Send_Voice_Messages
Allows sending voice messages.
@ View_Channel
Allows guild members to view a channel, which includes reading messages in text channels.
@ Use_External_Sounds
Allows the usage of custom soundboard sounds from other servers.
@ Manage_Events
Allows for creating, editing, and deleting scheduled events.
@ administrator
Allows all permissions and bypasses channel permission overwrites.
@ View_Creator_Monetization_Analytics
Allows for viewing role subscription insights.
@ Use_Application_Commands
Allows members to use application commands, including slash commands and context menu.
@ Manage_Messages
Allows for deletion of other users messages.
@ Use_VAD
Allows for using voice-activity-detection in a voice channel.
@ Manage_Nicknames
Allows for modification of other users nicknames.
@ Change_Nickname
Allows for modification of own nickname.
@ Create_Instant_Invite
Allows creation of instant invites.
@ speak
Allows for speaking in a voice channel.
@ Use_Soundboard
Allows for using soundboard in a voice channel.
@ Move_Members
Allows for moving of members between voice channels.
@ Send_Messages_in_Threads
Allows for sending messages in threads.
@ Priority_Speaker
Allows for using priority speaker in a voice channel.
@ Read_Message_History
Allows for reading of message history.
@ Manage_Guild_Expressions
Allows management and editing of emojis, stickers, and soundboard sounds.
@ Use_Embedded_Activities
Allows for using activities (applications with the embedded flag) in a voice channel.
@ Manage_Webhooks
Allows management and editing of webhooks.
@ Mute_Members
Allows for muting members in a voice channel.
@ Manage_Roles
Allows management and editing of roles.
@ Create_Private_Threads
Allows for creating protected threads.
@ Use_External_Emojis
Allows the usage of custom emojis from other servers.
@ Kick_Members
Allows kicking members.
@ View_Audit_Log
Allows for viewing of audit logs.
@ connect
Allows for joining of a voice channel.
@ Manage_Threads
Allows for deleting and archiving threads, and viewing all protected threads.
@ Create_Public_Threads
Allows for creating public and announcement threads.
@ Use_External_Stickers
Allows the usage of custom stickers from other servers.
@ Send_TTS_Messages
Allows for sending of /tts messages.
@ Manage_Channels
Allows management and editing of channels.
@ Ban_Members
Allows banning members.
@ Mention_Everyone
Allows for using the at-everyone tag to notify all users in a channel.
@ Attach_Files
Allows for uploading images and files.
@ Manage_Guild
Allows management and editing of the guild.
@ Moderate_Members
Allows for timing out users to prevent them from sending or reacting to messages in chat.
@ Request_to_Speak
Allows for requesting to speak in stage channels. (this permission is under active development).
@ Add_Reactions
Allows for the addition of reactions to messages.
@ Send_Messages
Allows for sending messages in a channel and creating threads in a forum.
@ Embed_Links
Links sent by users with this permission will be auto-embedded.
@ View_Guild_Insights
Allows for viewing guild insights.
@ Deafen_Members
Allows for deafening of members in a voice channel.
@ stream
Allows the user to go live.
auto newThreadAwaitable()
An awaitable that can be used to launch the co_routine onto a new thread - as well as return the hand...
Definition: Utilities.hpp:908
audio_frame_type
Audio frame types.
Definition: Utilities.hpp:374
stream_type
For selecting the type of streamer that the given bot is, one must be one server and one of client pe...
Definition: Base.hpp:837
static constexpr jsonifier::string_view blue_aquamarine
Blue aquamarine.
Definition: Utilities.hpp:343
static constexpr jsonifier::string_view submarine
Submarine.
Definition: Utilities.hpp:342
static constexpr jsonifier::string_view orange
Orange.
Definition: Utilities.hpp:328
static constexpr jsonifier::string_view ruby
Ruby.
Definition: Utilities.hpp:338
static constexpr jsonifier::string_view dark_gray
Dark gray.
Definition: Utilities.hpp:323
static constexpr jsonifier::string_view vivid_violet
Vivid violet.
Definition: Utilities.hpp:347
static constexpr jsonifier::string_view gray
Gray.
Definition: Utilities.hpp:322
static constexpr jsonifier::string_view raspberry
Raspberry.
Definition: Utilities.hpp:362
static constexpr jsonifier::string_view blue_green
Blue green.
Definition: Utilities.hpp:361
static constexpr jsonifier::string_view endeavour
Endeavor.
Definition: Utilities.hpp:346
static constexpr jsonifier::string_view discord_black
Discord black.
Definition: Utilities.hpp:325
static constexpr jsonifier::string_view red
Red.
Definition: Utilities.hpp:326
static constexpr jsonifier::string_view light_gray
Light gray.
Definition: Utilities.hpp:321
static constexpr jsonifier::string_view lime
Lime.
Definition: Utilities.hpp:357
static constexpr jsonifier::string_view medium_sea_green
Medium sea green.
Definition: Utilities.hpp:335
static constexpr jsonifier::string_view wrx_blue
Wrx blue.
Definition: Utilities.hpp:355
static constexpr jsonifier::string_view cadmium_green
cadmium green.
Definition: Utilities.hpp:359
static constexpr jsonifier::string_view tahiti_gold
Tahiti gold.
Definition: Utilities.hpp:340
static constexpr jsonifier::string_view black
Black.
Definition: Utilities.hpp:324
static constexpr jsonifier::string_view sti_blue
Sti blue.
Definition: Utilities.hpp:354
static constexpr jsonifier::string_view deep_sea
Deep sea.
Definition: Utilities.hpp:344
static constexpr jsonifier::string_view scarlet_red
Scarlet red.
Definition: Utilities.hpp:363
static constexpr jsonifier::string_view cinnabar
cinnabar.
Definition: Utilities.hpp:341
static constexpr jsonifier::string_view magenta
Magenta.
Definition: Utilities.hpp:331
static constexpr jsonifier::string_view gray_chateau
Gray chateau.
Definition: Utilities.hpp:352
static constexpr jsonifier::string_view white
White.
Definition: Utilities.hpp:319
static constexpr jsonifier::string_view jazzberry_jam
Jazzberry jam.
Definition: Utilities.hpp:348
static constexpr jsonifier::string_view forest_green
Forest green.
Definition: Utilities.hpp:358
static constexpr jsonifier::string_view blue
Blue.
Definition: Utilities.hpp:333
static constexpr jsonifier::string_view moon_yellow
Moon yellow.
Definition: Utilities.hpp:339
static constexpr jsonifier::string_view light_sea_green
Light sea green.
Definition: Utilities.hpp:334
static constexpr jsonifier::string_view rust
Rust.
Definition: Utilities.hpp:350
static constexpr jsonifier::string_view deep_lilac
Deep lilac.
Definition: Utilities.hpp:337
static constexpr jsonifier::string_view aquamarine
Aquamarine.
Definition: Utilities.hpp:360
static constexpr jsonifier::string_view summer_sky
Summer skye.
Definition: Utilities.hpp:336
static constexpr jsonifier::string_view yellow
Yellow.
Definition: Utilities.hpp:329
static constexpr jsonifier::string_view bismark
Bismark.
Definition: Utilities.hpp:353
static constexpr jsonifier::string_view sea_green
Sea green.
Definition: Utilities.hpp:345
static constexpr jsonifier::string_view pink
Pink.
Definition: Utilities.hpp:327
static constexpr jsonifier::string_view dark_goldenrod
Dark goldenrod.
Definition: Utilities.hpp:349
static constexpr jsonifier::string_view discord_white
Discord white.
Definition: Utilities.hpp:320
static constexpr jsonifier::string_view cyan
cyan.
Definition: Utilities.hpp:332
static constexpr jsonifier::string_view ralli_art_crimson
Ralliart crimson.
Definition: Utilities.hpp:356
static constexpr jsonifier::string_view brown
Brown.
Definition: Utilities.hpp:351
static constexpr jsonifier::string_view green
Green.
Definition: Utilities.hpp:330
The main namespace for the forward-facing interfaces.
jsonifier::string name
Name of the activity.
Definition: Utilities.hpp:68
jsonifier::string details
What the player is currently doing.
Definition: Utilities.hpp:65
snowflake applicationId
Application id for the game.
Definition: Utilities.hpp:66
jsonifier::string url
Stream url, is validated when type is 1.
Definition: Utilities.hpp:69
time_stamps timestamps
Timestamps object unix timestamps for start and / or end of the game.
Definition: Utilities.hpp:70
activity_type type
Activity's type.
Definition: Utilities.hpp:72
uint64_t createdAt
Unix timestamp(in milliseconds) of when the activity was added to the user's session.
Definition: Utilities.hpp:71
jsonifier::string state
User's current party status, or text used for a custom status.
Definition: Utilities.hpp:67
Represents a single frame of audio data.
Definition: Utilities.hpp:381
jsonifier::vector< uint8_t > data
The audio data.
Definition: Utilities.hpp:383
int64_t currentSize
The current size of the allocated memory.
Definition: Utilities.hpp:384
For selecting the caching style of the library.
Definition: Utilities.hpp:227
bool cacheGuildMembers
Do we cache guild_members?
Definition: Utilities.hpp:228
bool cacheVoiceStates
Do we cache voices states?
Definition: Utilities.hpp:229
bool cacheUsers
Do we cache users?
Definition: Utilities.hpp:233
bool cacheChannels
Do we cache channels?
Definition: Utilities.hpp:230
bool cacheRoles
Do we cache roles?
Definition: Utilities.hpp:232
bool cacheGuilds
Do we cache guilds?
Definition: Utilities.hpp:231
Configuration data for the library's main class, discord_core_client.
Definition: Utilities.hpp:237
gateway_intents intents
The gateway intents to be used for this instance.
Definition: Utilities.hpp:240
jsonifier::vector< repeated_function_data > functionsToExecute
Functions to execute after a timer, or on a repetition.
Definition: Utilities.hpp:239
text_format textFormat
Use etf or json format for websocket transfer?
Definition: Utilities.hpp:241
update_presence_data presenceData
Presence data to initialize your bot with.
Definition: Utilities.hpp:238
logging_options logOptions
Options for the output/logging of the library.
Definition: Utilities.hpp:245
uint16_t connectionPort
A potentially alternative connection port for the websocket.
Definition: Utilities.hpp:247
jsonifier::string botToken
Your bot's token.
Definition: Utilities.hpp:244
sharding_options shardOptions
Options for the sharding of your bot.
Definition: Utilities.hpp:243
jsonifier::string connectionAddress
A potentially alternative connection address for the websocket.
Definition: Utilities.hpp:242
cache_options cacheOptions
Options for the cache of the library.
Definition: Utilities.hpp:246
Loggin options for the library.
Definition: Utilities.hpp:215
bool logGeneralErrorMessages
Do we log general error messages to std::cout?
Definition: Utilities.hpp:221
bool logWebSocketErrorMessages
Do we log the websocket error messages to std::cout?
Definition: Utilities.hpp:219
bool logHttpsSuccessMessages
Do we log https response success messages to std::cout?
Definition: Utilities.hpp:222
bool logHttpsErrorMessages
Do we log https response error messages to std::cout?
Definition: Utilities.hpp:223
bool logWebSocketSuccessMessages
Do we log the websocket success messages to std::cout?
Definition: Utilities.hpp:218
bool logGeneralSuccessMessages
Do we log general success messages to std::cout?
Definition: Utilities.hpp:220
Function data for repeated functions to be loaded.
Definition: Utilities.hpp:194
std::function< void(discord_core_client *)> function
The std::function char* to be loaded.
Definition: Utilities.hpp:195
uint32_t intervalInMs
The time interval at which to call the std::function.
Definition: Utilities.hpp:196
bool repeated
Whether or not the std::function is repeating.
Definition: Utilities.hpp:197
Sharding options for the library.
Definition: Utilities.hpp:208
uint32_t numberOfShardsForThisProcess
The number of shards to launch on the current process.
Definition: Utilities.hpp:209
uint32_t startingShard
The first shard to start on this process.
Definition: Utilities.hpp:211
uint32_t totalNumberOfShards
The total number of shards that will be launched across all processes.
Definition: Utilities.hpp:210
For connecting two bots to stream the vc contents between the two.
Definition: Utilities.hpp:80
uint16_t port
The port to connect to.
Definition: Utilities.hpp:84
bool streamBotAudio
Do we stream the audio coming from other bots?
Definition: Utilities.hpp:81
jsonifier::string address
The address to connect to.
Definition: Utilities.hpp:82
stream_type type
The type of streamer that this is. set one to client and one to server.
Definition: Utilities.hpp:83
For updating a user's presence.
Definition: Utilities.hpp:131
For connecting to a voice-channel. "streamInfo" is used when a SOCKET is created to connect this bot ...
Definition: Utilities.hpp:403
int32_t currentShard
The current websocket shard, if applicable.
Definition: Utilities.hpp:405
snowflake channelId
The channel id to connect to.
Definition: Utilities.hpp:406
stream_info streamInfo
The info for the stream-SOCKET, if applicable.
Definition: Utilities.hpp:404
snowflake guildId
The guild id to connect to.
Definition: Utilities.hpp:407
snowflake userId
This bot's user id.
Definition: Utilities.hpp:408