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
34#include <discordcoreapi/Utilities/UnorderedMap.hpp>
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> jsonifierExcludedKeys{};
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
100 struct file;
101
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> jsonifierExcludedKeys{};
135 presence_update_state status{};///< current status.
136 int64_t since{};///< When was the activity started?
137 bool afk{};///< Are we afk.
138
139 DCA_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 class DiscordCoreAPI_Dll config_manager {
251 public:
252 config_manager() = default;
253
254 explicit config_manager(const discord_core_client_config&);
255
256 bool doWePrintWebSocketSuccessMessages() const;
257
258 bool doWePrintWebSocketErrorMessages() const;
259
260 bool doWePrintHttpsSuccessMessages() const;
261
262 bool doWePrintHttpsErrorMessages() const;
263
264 bool doWePrintGeneralSuccessMessages() const;
265
266 bool doWePrintGeneralErrorMessages() const;
267
268 bool doWeCacheGuildMembers() const;
269
270 bool doWeCacheVoiceStates() const;
271
272 bool doWeCacheChannels() const;
273
274 bool doWeCacheUsers() const;
275
276 bool doWeCacheGuilds() const;
277
278 bool doWeCacheRoles() const;
279
280 update_presence_data getPresenceData() const;
281
282 jsonifier::string getBotToken() const;
283
284 uint64_t getTotalShardCount() const;
285
286 std::ostream* getOutputStream() const;
287
288 std::ostream* getErrorStream() const;
289
290 uint64_t getStartingShard() const;
291
292 uint64_t getShardCountForThisProcess() const;
293
294 jsonifier::string getConnectionAddress() const;
295
296 void setConnectionAddress(jsonifier::string_view connectionAddressNew);
297
298 uint16_t getConnectionPort() const;
299
300 void setConnectionPort(const uint16_t connectionPortNew);
301
302 jsonifier::vector<repeated_function_data> getFunctionsToExecute() const;
303
304 text_format getTextFormat() const;
305
306 gateway_intents getGatewayIntents();
307
308 protected:
309 discord_core_client_config config{};
310 };
311
312 /// @brief Color constants for use in the embed_data color values.
313 namespace colors {
314 static constexpr jsonifier::string_view white{ "ffffff" },///< White.
315 discord_white{ "fffffe" },///< Discord white.
316 light_gray{ "c0_c0_c0" },///< Light gray.
317 gray{ "808080" },///< Gray.
318 dark_gray{ "404040" },///< Dark gray.
319 black{ "000000" },///< Black.
320 discord_black{ "000001" },///< Discord black.
321 red{ "ff0000" },///< Red.
322 pink{ "ffafaf" },///< Pink.
323 orange{ "ffc800" },///< Orange.
324 yellow{ "ffff00" },///< Yellow.
325 green{ "00FF00" },///< Green.
326 magenta{ "ff00_ff" },///< Magenta.
327 cyan{ "00FFFF" },///< cyan.
328 blue{ "0000FF" },///< Blue.
329 light_sea_green{ "1ABC9C" },///< Light sea green.
330 medium_sea_green{ "2ECC71" },///< Medium sea green.
331 summer_sky{ "3498DB" },///< Summer skye.
332 deep_lilac{ "9B59B6" },///< Deep lilac.
333 ruby{ "e91_e63" },///< Ruby.
334 moon_yellow{ "f1_c40_f" },///< Moon yellow.
335 tahiti_gold{ "e67_e22" },///< Tahiti gold.
336 cinnabar{ "e74_c3_c" },///< cinnabar.
337 submarine{ "95A5A6" },///< Submarine.
338 blue_aquamarine{ "607D8B" },///< Blue aquamarine.
339 deep_sea{ "11806A" },///< Deep sea.
340 sea_green{ "1F8B4C" },///< Sea green.
341 endeavour{ "206694" },///< Endeavor.
342 vivid_violet{ "71368A" },///< Vivid violet.
343 jazzberry_jam{ "ad1457" },///< Jazzberry jam.
344 dark_goldenrod{ "c27_c0_e" },///< Dark goldenrod.
345 rust{ "a84300" },///< Rust.
346 brown{ "992D22" },///< Brown.
347 gray_chateau{ "979C9F" },///< Gray chateau.
348 bismark{ "546E7A" },///< Bismark.
349 sti_blue{ "0E4BEF" },///< Sti blue.
350 wrx_blue{ "00247D" },///< Wrx blue.
351 ralli_art_crimson{ "e60012" },///< Ralliart crimson.
352 lime{ "00FF00" },///< Lime.
353 forest_green{ "228B22" },///< Forest green.
354 cadmium_green{ "097969" },///< cadmium green.
355 aquamarine{ "7FFFD4" },///< Aquamarine.
356 blue_green{ "088F8F" },///< Blue green.
357 raspberry{ "e30_b5_c" },///< Raspberry.
358 scarlet_red{ "ff2400" };///< Scarlet red.
359 };
360
361 /**@}*/
362
363 /**
364 * \addtogroup voice_connection
365 * @{
366 */
367
368 /// @brief Audio frame types.
369 enum class audio_frame_type : uint8_t {
370 Unset = 0,///< Unset.
371 raw_pcm = 1,///< Raw pcm.
372 encoded = 2,///< Encoded audio data.
373 };
374
375 /// @brief Represents a single frame of audio data.
376 struct DiscordCoreAPI_Dll audio_frame_data {
377 audio_frame_type type{ audio_frame_type::Unset };///< The type of audio frame.
378 jsonifier::vector<uint8_t> data{};///< The audio data.
379 int64_t currentSize{ -5 };///< The current size of the allocated memory.
380
381 audio_frame_data() = default;
382
383 audio_frame_data(audio_frame_type frameType);
384
385 audio_frame_data& operator+=(jsonifier::string_view_base<uint8_t>);
386
387 audio_frame_data& operator+=(jsonifier::vector<uint8_t>);
388
389 DCA_INLINE bool operator==(const audio_frame_data& rhs) const {
390 return currentSize == rhs.currentSize && data == rhs.data;
391 }
392
393 void clearData();
394 };
395
396 /// 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.
397 /// @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.
399 stream_info streamInfo{};///< The info for the stream-SOCKET, if applicable.
400 int32_t currentShard{};///< The current websocket shard, if applicable.
401 snowflake channelId{};///< The channel id to connect to.
402 snowflake guildId{};///< The guild id to connect to.
403 snowflake userId{};///< This bot's user id.
404 bool selfDeaf{};///< Self-deafen the bot?
405 bool selfMute{};///< Self-mute the bot?
406 };
407
408 /**@}*/
409
410 /**
411 * \addtogroup utilities
412 * @{
413 */
414
415 template<typename return_type> DCA_INLINE return_type fromString(jsonifier::string_view string, std::ios_base& (*type)( std::ios_base& )) {
416 return_type value{};
417 std::istringstream stream(std::string{ string });
418 stream >> type, stream >> value;
419 return value;
420 }
421
422 template<typename return_type> DCA_INLINE jsonifier::string toHex(return_type inputValue) {
423 std::stringstream stream{};
424 stream << std::setfill('0') << std::setw(sizeof(return_type) * 2) << std::hex << inputValue;
425 return jsonifier::string{ stream.str() };
426 }
427
428 class rgbcolor_value {
429 public:
430 uint8_t green{};
431 uint8_t blue{};
432 uint8_t red{};
433 };
434
435 using hex_color_value = jsonifier::string;
436
437 class DiscordCoreAPI_Dll color_value {
438 public:
439 template<typename value_type> friend struct jsonifier::core;
440
441 color_value(jsonifier::string_view hexColorValue);
442
443 rgbcolor_value getRgbColorValue();
444
445 hex_color_value getHexColorValue();
446
447 color_value(uint32_t colorValue);
448
449 uint32_t getIntColorValue();
450
451 protected:
452 uint32_t color{};
453 };
454
455 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 };
456
457 class DiscordCoreAPI_Dll icon_hash {
458 public:
459 icon_hash() = default;
460
461 icon_hash& operator=(jsonifier::string_view string);
462
463 icon_hash(jsonifier::string_view string);
464
465 bool operator==(jsonifier::string_view rhs) const;
466
467 bool operator==(const icon_hash& rhs) const;
468
469 friend jsonifier::string operator+(const icon_hash& lhs, jsonifier::string rhs);
470
471 operator jsonifier::string() const;
472
473 protected:
474 uint64_t highBits{};
475 uint64_t lowBits{};
476 };
477
478 /**@}*/
479
480 /**
481 * \addtogroup foundation_entities
482 * @{
483 */
484
485 /// @brief Permission values, for a given channel, by role_data or guild_member_data.
486 enum class permission : uint64_t {
487 Create_Instant_Invite = 0x0000000000000001,///< Allows creation of instant invites.
488 Kick_Members = 0x0000000000000002,///< Allows kicking members.
489 Ban_Members = 0x0000000000000004,///< Allows banning members.
490 administrator = 0x0000000000000008,///< Allows all permissions and bypasses channel permission overwrites.
491 Manage_Channels = 0x0000000000000010,///< Allows management and editing of channels.
492 Manage_Guild = 0x0000000000000020,///< Allows management and editing of the guild.
493 Add_Reactions = 0x0000000000000040,///< Allows for the addition of reactions to messages.
494 View_Audit_Log = 0x0000000000000080,///< Allows for viewing of audit logs.
495 Priority_Speaker = 0x0000000000000100,///< Allows for using priority speaker in a voice channel.
496 stream = 0x0000000000000200,///< Allows the user to go live.
497 View_Channel = 0x0000000000000400,///< Allows guild members to view a channel, which includes reading messages in text channels.
498 Send_Messages = 0x0000000000000800,///< Allows for sending messages in a channel and creating threads in a forum.
499 Send_TTS_Messages = 0x0000000000001000,///< Allows for sending of /tts messages.
500 Manage_Messages = 0x0000000000002000,///< Allows for deletion of other users messages.
501 Embed_Links = 0x0000000000004000,///< Links sent by users with this permission will be auto-embedded.
502 Attach_Files = 0x0000000000008000,///< Allows for uploading images and files.
503 Read_Message_History = 0x0000000000010000,///< Allows for reading of message history.
504 Mention_Everyone = 0x0000000000020000,///< Allows for using the at-everyone tag to notify all users in a channel.
505 Use_External_Emojis = 0x0000000000040000,///< Allows the usage of custom emojis from other servers.
506 View_Guild_Insights = 0x0000000000080000,///< Allows for viewing guild insights.
507 connect = 0x0000000000100000,///< Allows for joining of a voice channel.
508 speak = 0x0000000000200000,///< Allows for speaking in a voice channel.
509 Mute_Members = 0x0000000000400000,///< Allows for muting members in a voice channel.
510 Deafen_Members = 0x0000000000800000,///< Allows for deafening of members in a voice channel.
511 Move_Members = 0x0000000001000000,///< Allows for moving of members between voice channels.
512 Use_VAD = 0x0000000002000000,///< Allows for using voice-activity-detection in a voice channel.
513 Change_Nickname = 0x0000000004000000,///< Allows for modification of own nickname.
514 Manage_Nicknames = 0x0000000008000000,///< Allows for modification of other users nicknames.
515 Manage_Roles = 0x0000000010000000,///< Allows management and editing of roles.
516 Manage_Webhooks = 0x0000000020000000,///< Allows management and editing of webhooks.
517 Manage_Guild_Expressions = 0x0000000040000000,///< Allows management and editing of emojis, stickers, and soundboard sounds.
518 Use_Application_Commands = 0x0000000080000000,///< Allows members to use application commands, including slash commands and context menu.
519 Request_to_Speak = 0x0000000100000000,///< Allows for requesting to speak in stage channels. (this permission is under active development).
520 Manage_Events = 0x0000000200000000,///< Allows for creating, editing, and deleting scheduled events.
521 Manage_Threads = 0x0000000400000000,///< Allows for deleting and archiving threads, and viewing all protected threads.
522 Create_Public_Threads = 0x0000000800000000,///< Allows for creating public and announcement threads.
523 Create_Private_Threads = 0x0000001000000000,///< Allows for creating protected threads.
524 Use_External_Stickers = 0x0000002000000000,///< Allows the usage of custom stickers from other servers.
525 Send_Messages_in_Threads = 0x0000004000000000,///< Allows for sending messages in threads.
526 Use_Embedded_Activities = 0x0000008000000000,///< Allows for using activities (applications with the embedded flag) in a voice channel.
527 Moderate_Members = 0x0000010000000000,///< Allows for timing out users to prevent them from sending or reacting to messages in chat.
528 View_Creator_Monetization_Analytics = 0x0000020000000000,///< Allows for viewing role subscription insights.
529 Use_Soundboard = 0x0000040000000000,///< Allows for using soundboard in a voice channel.
530 Use_External_Sounds = 0x0000200000000000,///< Allows the usage of custom soundboard sounds from other servers.
531 Send_Voice_Messages = 0x0000400000000000,///< Allows sending voice messages.
532 };
533
534 /// @brief Permissions_base class, for representing and manipulating permission values.
535 template<typename value_type> class permissions_base {
536 public:
537
538 /// @brief Returns a string containing all of a given user's permissions_base for a given channel.
539 /// @param guildMember the guild_member_data who's permissions_base to analyze.
540 /// @param channel the channel_data withint which to check for permissions_base.
541 /// @return jsonifier::string a string containing the final permission's value for a given channel.
542 DCA_INLINE static jsonifier::string getCurrentChannelPermissions(const guild_member_data& guildMember, const channel_data& channel) {
543 return computePermissions(guildMember, channel);
544 }
545
546 /// @brief Checks for a given permission in a chosen channel_data, for a specific user_data.
547 /// @param guildMember the guild_member_data who to check the permissions_base of.
548 /// @param channel the channel_data within which to check for the permission's presence.
549 /// @param permission a permission to check the current channel_data for.
550 /// @return bool a bool suggesting the presence of the chosen permission.
551 DCA_INLINE bool checkForPermission(const guild_member_data& guildMember, const channel_data& channel, permission permission) {
552 if ((jsonifier::strToUint64(computePermissions(guildMember, channel).data()) & static_cast<uint64_t>(permission)) == static_cast<uint64_t>(permission)) {
553 return true;
554 } else {
555 return false;
556 }
557 }
558
559 /// @brief Returns a string containing the currently held permissions_base in a given guild.
560 /// @param guildMember the guild_member_data who's permissions_base are to be evaluated.
561 /// @return jsonifier::string a string containing the current permissions_base.
562 DCA_INLINE static jsonifier::string getCurrentGuildPermissions(const guild_member_data& guildMember) {
563 permissions_base setValue(computeBasePermissions(guildMember));
564 return static_cast<value_type*>(setValue);
565 }
566
567 /// @brief Removes one or more permissions_base from the current permissions_base value.
568 /// @param permissionsToRemove a vector containing the permissions_base you wish to remove.
569 DCA_INLINE void removePermissions(const jsonifier::vector<permission>& permissionsToRemove) {
570 uint64_t permissionsInteger = *static_cast<value_type*>(this);
571 for (auto valueNew: permissionsToRemove) {
572 permissionsInteger &= ~static_cast<uint64_t>(valueNew);
573 }
574 std::stringstream sstream{};
575 sstream << permissionsInteger;
576 *static_cast<value_type*>(this) = jsonifier::string{ sstream.str() };
577 }
578
579 /// @brief Adds one or more permissions_base to the current permissions_base value.
580 /// @param permissionsToAdd a vector containing the permissions_base you wish to add.
581 DCA_INLINE void addPermissions(const jsonifier::vector<permission>& permissionsToAdd) {
582 uint64_t permissionsInteger = *static_cast<value_type*>(this);
583 for (auto valueNew: permissionsToAdd) {
584 permissionsInteger |= static_cast<uint64_t>(valueNew);
585 }
586 std::stringstream sstream{};
587 sstream << permissionsInteger;
588 *static_cast<value_type*>(this) = jsonifier::string{ sstream.str() };
589 }
590
591 /// @brief Displays the currently present permissions_base in a string, and returns A vector with each of them stored in string format.
592 /// @return jsonifier::vector a vector full of strings of the permissions_base that are in the input jsonifier::string's value.
593 DCA_INLINE jsonifier::vector<jsonifier::string> displayPermissions() {
594 jsonifier::vector<jsonifier::string> returnVector{};
595 uint64_t permissionsInteger = *static_cast<value_type*>(this);
596 if (permissionsInteger & (1ll << 3)) {
597 for (int64_t x = 0; x < 46; ++x) {
598 permissionsInteger |= 1ll << x;
599 }
600 }
601 if (permissionsInteger & static_cast<uint64_t>(permission::Create_Instant_Invite)) {
602 returnVector.emplace_back("create instant invite");
603 }
604 if (permissionsInteger & static_cast<uint64_t>(permission::Kick_Members)) {
605 returnVector.emplace_back("kick members");
606 }
607 if (permissionsInteger & static_cast<uint64_t>(permission::Ban_Members)) {
608 returnVector.emplace_back("ban members");
609 }
610 if (permissionsInteger & static_cast<uint64_t>(permission::administrator)) {
611 returnVector.emplace_back("administrator");
612 }
613 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Channels)) {
614 returnVector.emplace_back("manage channels");
615 }
616 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Guild)) {
617 returnVector.emplace_back("manage guild");
618 }
619 if (permissionsInteger & static_cast<uint64_t>(permission::Add_Reactions)) {
620 returnVector.emplace_back("add reactions");
621 }
622 if (permissionsInteger & static_cast<uint64_t>(permission::View_Audit_Log)) {
623 returnVector.emplace_back("view audit log");
624 }
625 if (permissionsInteger & static_cast<uint64_t>(permission::Priority_Speaker)) {
626 returnVector.emplace_back("priority speaker");
627 }
628 if (permissionsInteger & static_cast<uint64_t>(permission::stream)) {
629 returnVector.emplace_back("stream");
630 }
631 if (permissionsInteger & static_cast<uint64_t>(permission::View_Channel)) {
632 returnVector.emplace_back("view channel");
633 }
634 if (permissionsInteger & static_cast<uint64_t>(permission::Send_Messages)) {
635 returnVector.emplace_back("send messages");
636 }
637 if (permissionsInteger & static_cast<uint64_t>(permission::Send_TTS_Messages)) {
638 returnVector.emplace_back("send tts messages");
639 }
640 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Messages)) {
641 returnVector.emplace_back("manage messages");
642 }
643 if (permissionsInteger & static_cast<uint64_t>(permission::Embed_Links)) {
644 returnVector.emplace_back("embed links");
645 }
646 if (permissionsInteger & static_cast<uint64_t>(permission::Attach_Files)) {
647 returnVector.emplace_back("attach files");
648 }
649 if (permissionsInteger & static_cast<uint64_t>(permission::Read_Message_History)) {
650 returnVector.emplace_back("read message history");
651 }
652 if (permissionsInteger & static_cast<uint64_t>(permission::Mention_Everyone)) {
653 returnVector.emplace_back("mention everyone");
654 }
655 if (permissionsInteger & static_cast<uint64_t>(permission::Use_External_Emojis)) {
656 returnVector.emplace_back("use external emoji");
657 }
658 if (permissionsInteger & static_cast<uint64_t>(permission::View_Guild_Insights)) {
659 returnVector.emplace_back("view guild insights");
660 }
661 if (permissionsInteger & static_cast<uint64_t>(permission::connect)) {
662 returnVector.emplace_back("connect");
663 }
664 if (permissionsInteger & static_cast<uint64_t>(permission::speak)) {
665 returnVector.emplace_back("speak");
666 }
667 if (permissionsInteger & static_cast<uint64_t>(permission::Mute_Members)) {
668 returnVector.emplace_back("mute members");
669 }
670 if (permissionsInteger & static_cast<uint64_t>(permission::Deafen_Members)) {
671 returnVector.emplace_back("deafen members");
672 }
673 if (permissionsInteger & static_cast<uint64_t>(permission::Move_Members)) {
674 returnVector.emplace_back("move members");
675 }
676 if (permissionsInteger & static_cast<uint64_t>(permission::Use_VAD)) {
677 returnVector.emplace_back("use vad");
678 }
679 if (permissionsInteger & static_cast<uint64_t>(permission::Change_Nickname)) {
680 returnVector.emplace_back("change nickname");
681 }
682 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Nicknames)) {
683 returnVector.emplace_back("manage nicknames");
684 }
685 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Roles)) {
686 returnVector.emplace_back("manage roles");
687 }
688 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Webhooks)) {
689 returnVector.emplace_back("manage webhooks");
690 }
691 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Guild_Expressions)) {
692 returnVector.emplace_back("manage emojis and stickers");
693 }
694 if (permissionsInteger & static_cast<uint64_t>(permission::Use_Application_Commands)) {
695 returnVector.emplace_back("use application commands");
696 }
697 if (permissionsInteger & static_cast<uint64_t>(permission::Request_to_Speak)) {
698 returnVector.emplace_back("request to speak");
699 }
700 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Events)) {
701 returnVector.emplace_back("manage events");
702 }
703 if (permissionsInteger & static_cast<uint64_t>(permission::Manage_Threads)) {
704 returnVector.emplace_back("manage threads");
705 }
706 if (permissionsInteger & static_cast<uint64_t>(permission::Create_Public_Threads)) {
707 returnVector.emplace_back("create public threads");
708 }
709 if (permissionsInteger & static_cast<uint64_t>(permission::Create_Private_Threads)) {
710 returnVector.emplace_back("create private threads");
711 }
712 if (permissionsInteger & static_cast<uint64_t>(permission::Use_External_Stickers)) {
713 returnVector.emplace_back("use external stickers");
714 }
715 if (permissionsInteger & static_cast<uint64_t>(permission::Send_Messages_in_Threads)) {
716 returnVector.emplace_back("send messages in threads");
717 }
718 if (permissionsInteger & static_cast<uint64_t>(permission::Use_Embedded_Activities)) {
719 returnVector.emplace_back("start embedded activities");
720 }
721 if (permissionsInteger & static_cast<uint64_t>(permission::Moderate_Members)) {
722 returnVector.emplace_back("moderate members");
723 }
724 if (permissionsInteger & static_cast<uint64_t>(permission::View_Creator_Monetization_Analytics)) {
725 returnVector.emplace_back("view creator monetization analytics");
726 }
727 if (permissionsInteger & static_cast<uint64_t>(permission::Use_Soundboard)) {
728 returnVector.emplace_back("use soundboard");
729 }
730 if (permissionsInteger & static_cast<uint64_t>(permission::Use_External_Sounds)) {
731 returnVector.emplace_back("use external sounds");
732 }
733 if (permissionsInteger & static_cast<uint64_t>(permission::Send_Voice_Messages)) {
734 returnVector.emplace_back("send voice messages");
735 }
736 return returnVector;
737 }
738
739 /// @brief Returns a string containing the currently held permissions_base.
740 /// @return jsonifier::string a string containing the current permissions_base.
741 DCA_INLINE jsonifier::string getCurrentPermissionString() {
742 jsonifier::string returnString = *static_cast<value_type*>(this);
743 return returnString;
744 }
745
746 /// @brief Returns a string containing all of the possible permissions_base.
747 /// @return jsonifier::string a string containing all of the possible permissions_base.
748 DCA_INLINE static jsonifier::string getAllPermissions() {
749 uint64_t allPerms{};
750 for (int64_t x = 0; x < 46; ++x) {
751 allPerms |= 1ll << x;
752 }
753 std::stringstream stream{};
754 stream << allPerms;
755 return jsonifier::string{ stream.str() };
756 }
757
758 protected:
759 DCA_INLINE permissions_base() = default;
760
761 DiscordCoreAPI_Dll static jsonifier::string computeOverwrites(jsonifier::string_view basePermissions, const guild_member_data& guildMember, const channel_data& channel);
762
763 DCA_INLINE static jsonifier::string computePermissions(const guild_member_data& guildMember, const channel_data& channel) {
764 jsonifier::string permissions = computeBasePermissions(guildMember);
765 permissions = computeOverwrites(permissions, guildMember, channel);
766 return permissions;
767 }
768
769 DiscordCoreAPI_Dll static jsonifier::string computeBasePermissions(const guild_member_data& guildMember);
770 };
771
772 class permissions_parse : public permissions_base<permissions_parse>, public jsonifier::string {
773 public:
774 template<typename value_type> friend class permissions_base;
775
776 DCA_INLINE permissions_parse() = default;
777
778 DCA_INLINE permissions_parse& operator=(jsonifier::string_view valueNew) {
779 resize(valueNew.size());
780 std::memcpy(data(), valueNew.data(), size());
781 return *this;
782 }
783
784 DCA_INLINE permissions_parse(jsonifier::string_view valueNew) {
785 *this = valueNew;
786 }
787
788 DCA_INLINE permissions_parse& operator=(uint64_t valueNew) {
789 *this = jsonifier::toString(valueNew);
790 return *this;
791 }
792
793 DCA_INLINE permissions_parse(uint64_t valueNew) {
794 *this = valueNew;
795 }
796
797 DCA_INLINE permissions_parse substr(uint64_t offset, uint64_t count) const {
798 return substr(offset, count);
799 }
800
801 DCA_INLINE uint64_t size() const {
802 return jsonifier::string::size();
803 }
804
805 DCA_INLINE char* data() const {
806 return jsonifier::string::data();
807 }
808
809 DCA_INLINE operator uint64_t() const {
810 return jsonifier::strToUint64(data());
811 }
812 };
813
814 class permissions : public permissions_base<permissions> {
815 public:
816 template<typename value_type> friend class permissions_base;
817
818 DCA_INLINE permissions() = default;
819
820 DCA_INLINE permissions& operator=(const permissions_parse& other) {
821 value = other.operator uint64_t();
822 return *this;
823 }
824
825 DCA_INLINE permissions(const permissions_parse& other) {
826 *this = other;
827 }
828
829 DCA_INLINE permissions& operator=(jsonifier::string_view valueNew) {
830 value = jsonifier::strToUint64(valueNew.data());
831 return *this;
832 }
833
834 DCA_INLINE permissions(jsonifier::string_view valueNew) {
835 *this = valueNew;
836 }
837
838 DCA_INLINE permissions& operator=(jsonifier::string&& valueNew) {
839 value = jsonifier::strToUint64(valueNew.data());
840 return *this;
841 }
842
843 DCA_INLINE permissions(jsonifier::string&& valueNew) {
844 *this = std::move(valueNew);
845 }
846
847 DCA_INLINE permissions& operator=(uint64_t valueNew) {
848 value = valueNew;
849 return *this;
850 }
851
852 DCA_INLINE permissions(uint64_t valueNew) {
853 *this = valueNew;
854 }
855
856 DCA_INLINE operator uint64_t() const {
857 return value;
858 }
859
860 DCA_INLINE operator jsonifier::string() const {
861 return jsonifier::toString(value);
862 }
863
864 protected:
865 uint64_t value{};
866 };
867
868 DiscordCoreAPI_Dll jsonifier::string constructMultiPartData(jsonifier::string_view data, const jsonifier::vector<file>& files);
869
870 DiscordCoreAPI_Dll jsonifier::string convertToLowerCase(jsonifier::string_view stringToConvert);
871
872 DiscordCoreAPI_Dll jsonifier::string base64Encode(jsonifier::string_view, bool = false);
873
874 DiscordCoreAPI_Dll jsonifier::string loadFileContents(jsonifier::string_view filePath);
875
876 DiscordCoreAPI_Dll jsonifier::string utf8MakeValid(jsonifier::string_view inputString);
877
878 DiscordCoreAPI_Dll jsonifier::string urlEncode(jsonifier::string_view inputString);
879
880 DiscordCoreAPI_Dll void spinLock(uint64_t timeInNsToSpinLockFor);
881
882 DiscordCoreAPI_Dll jsonifier::string generateBase64EncodedKey();
883
884 DiscordCoreAPI_Dll bool nanoSleep(int64_t ns);
885
886 /// @brief Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
887 /// @return jsonifier::string a string containing the current date-time stamp.
888 DiscordCoreAPI_Dll jsonifier::string getTimeAndDate();
889
890 /**@}*/
891
892 /**
893 * \addtogroup utilities
894 * @{
895 */
896 template<typename return_type, bool timeOut = true> class new_thread_awaiter;
897
898 /// @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.
899 /// @tparam return_type the type of value returned by the containing co_routine.
900 /// @tparam timeOut whether or not to time out the co_routine's execution after a period of time.
901 /// @return new_thread_awaiter<return_type, timeOut> a new_thread_awaiter for suspendint the current co_routine's execution.
902 template<typename return_type, bool timeOut = true> DCA_INLINE auto newThreadAwaitable() {
904 }
905
906 /**@}*/
907};
A type of user_data, to represent the bot and some of its associated endpoints.
A co_routine - representing a potentially asynchronous operation/function.
A class for handling commands from user input.
discord_core_client - the main class for this library.
A websocket client, for communication via a tcp-connection.
Data structure representing a single guild_member_data.
An interface class for the guild_member_data related discord endpoints.
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...
Permissions_base class, for representing and manipulating permission values.
DCA_INLINE void removePermissions(const jsonifier::vector< permission > &permissionsToRemove)
Removes one or more permissions_base from the current permissions_base value.
static DCA_INLINE jsonifier::string getCurrentGuildPermissions(const guild_member_data &guildMember)
Returns a string containing the currently held permissions_base in a given guild.
static DCA_INLINE 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.
DCA_INLINE void addPermissions(const jsonifier::vector< permission > &permissionsToAdd)
Adds one or more permissions_base to the current permissions_base value.
static DCA_INLINE jsonifier::string getAllPermissions()
Returns a string containing all of the possible permissions_base.
DCA_INLINE jsonifier::string getCurrentPermissionString()
Returns a string containing the currently held permissions_base.
DCA_INLINE jsonifier::vector< jsonifier::string > displayPermissions()
Displays the currently present permissions_base in a string, and returns A vector with each of them s...
DCA_INLINE 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.
An interface class for the reaction_data related discord endpoints.
voice_connection class - represents the connection to a given voice channel_data.
input_event_response_type
Input event response types.
text_format
Represents which text format to use for websocket transfer.
activity_type
Activity types.
Definition Utilities.hpp:48
gateway_intents
Gateway intents.
permission
Permission values, for a given channel, by role_data or guild_member_data.
DiscordCoreAPI_Dll jsonifier::string getTimeAndDate()
Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
@ 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.
DCA_INLINE auto newThreadAwaitable()
An awaitable that can be used to launch the co_routine onto a new thread - as well as return the hand...
audio_frame_type
Audio frame types.
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:868
Color constants for use in the embed_data color values.
static constexpr jsonifier::string_view blue_aquamarine
Blue aquamarine.
static constexpr jsonifier::string_view submarine
Submarine.
static constexpr jsonifier::string_view orange
Orange.
static constexpr jsonifier::string_view ruby
Ruby.
static constexpr jsonifier::string_view dark_gray
Dark gray.
static constexpr jsonifier::string_view vivid_violet
Vivid violet.
static constexpr jsonifier::string_view gray
Gray.
static constexpr jsonifier::string_view raspberry
Raspberry.
static constexpr jsonifier::string_view blue_green
Blue green.
static constexpr jsonifier::string_view endeavour
Endeavor.
static constexpr jsonifier::string_view discord_black
Discord black.
static constexpr jsonifier::string_view red
Red.
static constexpr jsonifier::string_view light_gray
Light gray.
static constexpr jsonifier::string_view lime
Lime.
static constexpr jsonifier::string_view medium_sea_green
Medium sea green.
static constexpr jsonifier::string_view wrx_blue
Wrx blue.
static constexpr jsonifier::string_view cadmium_green
cadmium green.
static constexpr jsonifier::string_view tahiti_gold
Tahiti gold.
static constexpr jsonifier::string_view black
Black.
static constexpr jsonifier::string_view sti_blue
Sti blue.
static constexpr jsonifier::string_view deep_sea
Deep sea.
static constexpr jsonifier::string_view scarlet_red
Scarlet red.
static constexpr jsonifier::string_view cinnabar
cinnabar.
static constexpr jsonifier::string_view magenta
Magenta.
static constexpr jsonifier::string_view gray_chateau
Gray chateau.
static constexpr jsonifier::string_view white
White.
static constexpr jsonifier::string_view jazzberry_jam
Jazzberry jam.
static constexpr jsonifier::string_view forest_green
Forest green.
static constexpr jsonifier::string_view blue
Blue.
static constexpr jsonifier::string_view moon_yellow
Moon yellow.
static constexpr jsonifier::string_view light_sea_green
Light sea green.
static constexpr jsonifier::string_view rust
Rust.
static constexpr jsonifier::string_view deep_lilac
Deep lilac.
static constexpr jsonifier::string_view aquamarine
Aquamarine.
static constexpr jsonifier::string_view summer_sky
Summer skye.
static constexpr jsonifier::string_view yellow
Yellow.
static constexpr jsonifier::string_view bismark
Bismark.
static constexpr jsonifier::string_view sea_green
Sea green.
static constexpr jsonifier::string_view pink
Pink.
static constexpr jsonifier::string_view dark_goldenrod
Dark goldenrod.
static constexpr jsonifier::string_view discord_white
Discord white.
static constexpr jsonifier::string_view cyan
cyan.
static constexpr jsonifier::string_view ralli_art_crimson
Ralliart crimson.
static constexpr jsonifier::string_view brown
Brown.
static constexpr jsonifier::string_view green
Green.
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.
jsonifier::vector< uint8_t > data
The audio data.
int64_t currentSize
The current size of the allocated memory.
For selecting the caching style of the library.
bool cacheGuildMembers
Do we cache guild_members?
bool cacheVoiceStates
Do we cache voices states?
bool cacheUsers
Do we cache users?
bool cacheChannels
Do we cache channels?
bool cacheRoles
Do we cache roles?
bool cacheGuilds
Do we cache guilds?
Configuration data for the library's main class, discord_core_client.
gateway_intents intents
The gateway intents to be used for this instance.
jsonifier::vector< repeated_function_data > functionsToExecute
Functions to execute after a timer, or on a repetition.
text_format textFormat
Use etf or json format for websocket transfer?
update_presence_data presenceData
Presence data to initialize your bot with.
logging_options logOptions
Options for the output/logging of the library.
uint16_t connectionPort
A potentially alternative connection port for the websocket.
jsonifier::string botToken
Your bot's token.
sharding_options shardOptions
Options for the sharding of your bot.
jsonifier::string connectionAddress
A potentially alternative connection address for the websocket.
cache_options cacheOptions
Options for the cache of the library.
Data representing a file to be sent via multipart-form data.
Loggin options for the library.
bool logGeneralErrorMessages
Do we log general error messages to std::cout?
bool logWebSocketErrorMessages
Do we log the websocket error messages to std::cout?
bool logHttpsSuccessMessages
Do we log https response success messages to std::cout?
bool logHttpsErrorMessages
Do we log https response error messages to std::cout?
bool logWebSocketSuccessMessages
Do we log the websocket success messages to std::cout?
bool logGeneralSuccessMessages
Do we log general success messages to std::cout?
Data that is received as part of a voice server update event.
Data that is received as part of a voice state update event.
Function data for repeated functions to be loaded.
std::function< void(discord_core_client *)> function
The std::function char* to be loaded.
uint32_t intervalInMs
The time interval at which to call the std::function.
bool repeated
Whether or not the std::function is repeating.
Sharding options for the library.
uint32_t numberOfShardsForThisProcess
The number of shards to launch on the current process.
uint32_t startingShard
The first shard to start on this process.
uint32_t totalNumberOfShards
The total number of shards that will be launched across all processes.
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.
For connecting to a voice-channel. "streamInfo" is used when a SOCKET is created to connect this bot ...
int32_t currentShard
The current websocket shard, if applicable.
snowflake channelId
The channel id to connect to.
stream_info streamInfo
The info for the stream-SOCKET, if applicable.
snowflake guildId
The guild id to connect to.
snowflake userId
This bot's user id.