DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
Utilities.hpp File Reference
#include <jsonifier/Jsonifier.hpp>
#include <source_location>
#include <unordered_map>
#include <unordered_set>
#include <shared_mutex>
#include <immintrin.h>
#include <string_view>
#include <functional>
#include <concepts>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <intrin.h>
#include <cassert>
#include <vector>
#include <atomic>
#include <random>
#include <string>
#include <memory>
#include <thread>
#include <mutex>
#include <queue>
#include <chrono>
#include <bitset>
#include <array>
#include <deque>
#include <map>
Include dependency graph for Utilities.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes and Structures

struct  DiscordCoreAPI::AudioFrameData
 Represents a single frame of audio data. More...
 
struct  DiscordCoreAPI::CacheOptions
 For selecting the caching style of the library. More...
 
struct  DiscordCoreAPI::DiscordCoreClientConfig
 Configuration data for the library's main class, DiscordCoreClient. More...
 
struct  DiscordCoreAPI::LoggingOptions
 Loggin options for the library. More...
 
class  DiscordCoreAPI::Permissions
 Permissions class, for representing and manipulating Permission values. More...
 
struct  DiscordCoreAPI::RepeatedFunctionData
 Function data for repeated functions to be loaded. More...
 
struct  DiscordCoreAPI::ShardingOptions
 Sharding options for the library. More...
 
struct  DiscordCoreAPI::StreamInfo
 For connecting two bots to stream the VC contents between the two. More...
 
class  DiscordCoreAPI::TimeStamp
 Class for representing a timeStamp, as well as working with time-related values. More...
 
class  DiscordCoreAPI::UnboundedMessageBlock< OTy >
 A thread-safe messaging block for data-structures. More...
 
struct  DiscordCoreAPI::UpdatePresenceData
 For updating a User's presence. More...
 
struct  DiscordCoreAPI::VoiceConnectInitData
 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. More...
 
class  DiscordCoreInternal::HttpsResponseCode
 Voice Websocket close codes. More...
 
class  DiscordCoreInternal::VoiceWebSocketClose
 Voice Websocket close codes. More...
 
class  DiscordCoreInternal::WebSocketClose
 Websocket close codes. More...
 

Namespaces

namespace  DiscordCoreAPI
 The main namespace for this library.
 
namespace  DiscordCoreAPI::Colors
 Color constants for use in the EmbedData color values.
 

Typedefs

template<typename OTy >
using DiscordCoreAPI::ObjectFilter = std::function< bool(OTy)>
 Typedef for the message filter.
 

Enumerations

enum class  DiscordCoreAPI::AudioFrameType : uint8_t { DiscordCoreAPI::AudioFrameType::Unset = 0 , DiscordCoreAPI::AudioFrameType::RawPCM = 1 , DiscordCoreAPI::AudioFrameType::Skip = 2 }
 Audio frame types. More...
 
enum class  DiscordCoreAPI::GatewayIntents : uint32_t {
  DiscordCoreAPI::GatewayIntents::Guilds = 1 << 0 , DiscordCoreAPI::GatewayIntents::Guild_Members = 1 << 1 , DiscordCoreAPI::GatewayIntents::Guild_Bans = 1 << 2 , DiscordCoreAPI::GatewayIntents::Guild_Emojis = 1 << 3 ,
  DiscordCoreAPI::GatewayIntents::Guild_Integrations = 1 << 4 , DiscordCoreAPI::GatewayIntents::Guild_Webhooks = 1 << 5 , DiscordCoreAPI::GatewayIntents::Guild_Invites = 1 << 6 , DiscordCoreAPI::GatewayIntents::Guild_VoiceStates = 1 << 7 ,
  DiscordCoreAPI::GatewayIntents::Guild_Presences = 1 << 8 , DiscordCoreAPI::GatewayIntents::Guild_Messages = 1 << 9 , DiscordCoreAPI::GatewayIntents::Guild_Message_Reactions = 1 << 10 , DiscordCoreAPI::GatewayIntents::Guild_Message_Typing = 1 << 11 ,
  DiscordCoreAPI::GatewayIntents::Direct_Messages = 1 << 12 , DiscordCoreAPI::GatewayIntents::Direct_Message_Reactions = 1 << 13 , DiscordCoreAPI::GatewayIntents::Direct_Message_Typing = 1 << 14 , DiscordCoreAPI::GatewayIntents::Message_Content = 1 << 15 ,
  DiscordCoreAPI::GatewayIntents::Guild_Scheduled_Events = 1 << 16 , DiscordCoreAPI::GatewayIntents::Default_Intents , DiscordCoreAPI::GatewayIntents::Privileged_Intents = Guild_Members | Guild_Presences | Message_Content , DiscordCoreAPI::GatewayIntents::All_Intents = Default_Intents | Privileged_Intents
}
 Gateway intents. More...
 
enum class  DiscordCoreAPI::InputEventResponseType : uint8_t {
  DiscordCoreAPI::InputEventResponseType::Unset = 0 , Deferred_Response = 1 , DiscordCoreAPI::InputEventResponseType::Ephemeral_Deferred_Response = 2 , DiscordCoreAPI::InputEventResponseType::Interaction_Response = 3 ,
  DiscordCoreAPI::InputEventResponseType::Ephemeral_Interaction_Response = 4 , DiscordCoreAPI::InputEventResponseType::Edit_Interaction_Response = 5 , DiscordCoreAPI::InputEventResponseType::Follow_Up_Message = 6 , DiscordCoreAPI::InputEventResponseType::Ephemeral_Follow_Up_Message = 7 ,
  DiscordCoreAPI::InputEventResponseType::Edit_Follow_Up_Message = 8 , DiscordCoreAPI::InputEventResponseType::Application_Command_AutoComplete_Result = 9 , DiscordCoreAPI::InputEventResponseType::Modal_Interaction_Response = 10
}
 Input event response types. More...
 
enum class  DiscordCoreAPI::Permission : uint64_t {
  DiscordCoreAPI::Permission::Create_Instant_Invite = 1ull << 0 , DiscordCoreAPI::Permission::Kick_Members = 1ull << 1 , DiscordCoreAPI::Permission::Ban_Members = 1ull << 2 , DiscordCoreAPI::Permission::Administrator = 1ull << 3 ,
  DiscordCoreAPI::Permission::Manage_Channels = 1ull << 4 , DiscordCoreAPI::Permission::Manage_Guild = 1ull << 5 , DiscordCoreAPI::Permission::Add_Reactions = 1ull << 6 , DiscordCoreAPI::Permission::View_Audit_Log = 1ull << 7 ,
  DiscordCoreAPI::Permission::Priority_Speaker = 1ull << 8 , DiscordCoreAPI::Permission::Stream = 1ull << 9 , DiscordCoreAPI::Permission::View_Channel = 1ull << 10 , DiscordCoreAPI::Permission::Send_Messages = 1ull << 11 ,
  DiscordCoreAPI::Permission::Send_Tts_Messages = 1ull << 12 , DiscordCoreAPI::Permission::Manage_Messages = 1ull << 13 , DiscordCoreAPI::Permission::Embed_Links = 1ull << 14 , DiscordCoreAPI::Permission::Attach_Files = 1ull << 15 ,
  DiscordCoreAPI::Permission::Read_Message_History = 1ull << 16 , DiscordCoreAPI::Permission::Mention_Everyone = 1ull << 17 , DiscordCoreAPI::Permission::Use_External_Emojis = 1ull << 18 , DiscordCoreAPI::Permission::View_Guild_Insights = 1ull << 19 ,
  DiscordCoreAPI::Permission::Connect = 1ull << 20 , DiscordCoreAPI::Permission::Speak = 1ull << 21 , DiscordCoreAPI::Permission::Mute_Members = 1ull << 22 , DiscordCoreAPI::Permission::Deafen_Members = 1ull << 23 ,
  DiscordCoreAPI::Permission::Move_Members = 1ull << 24 , DiscordCoreAPI::Permission::Use_Vad = 1ull << 25 , DiscordCoreAPI::Permission::Change_Nickname = 1ull << 26 , DiscordCoreAPI::Permission::Manage_Nicknames = 1ull << 27 ,
  DiscordCoreAPI::Permission::Manage_Roles = 1ull << 28 , DiscordCoreAPI::Permission::Manage_Webhooks = 1ull << 29 , DiscordCoreAPI::Permission::Manage_Emojis_And_Stickers = 1ull << 30 , DiscordCoreAPI::Permission::Use_Application_Commands = 1ull << 31 ,
  DiscordCoreAPI::Permission::Request_To_Speak = 1ull << 32 , DiscordCoreAPI::Permission::Manage_Events = 1ull << 33 , DiscordCoreAPI::Permission::Manage_Threads = 1ull << 34 , DiscordCoreAPI::Permission::Create_Public_Threads = 1ull << 35 ,
  DiscordCoreAPI::Permission::Create_Private_Threads = 1ull << 36 , DiscordCoreAPI::Permission::Use_External_Stickers = 1ull << 37 , DiscordCoreAPI::Permission::Send_Messages_In_Threads = 1ull << 38 , DiscordCoreAPI::Permission::Start_Embedded_Activities = 1ull << 39 ,
  DiscordCoreAPI::Permission::Moderate_Members = 1ull << 40
}
 Permission values, for a given Channel, by Role or GuildMember. More...
 
enum class  DiscordCoreAPI::StreamType
 For selecting the type of streamer that the given bot is, one must be one server and one of client per connection.
 
enum class  DiscordCoreAPI::TextFormat : uint8_t { DiscordCoreAPI::TextFormat::Etf = 0x00 , DiscordCoreAPI::TextFormat::Json = 0x01 }
 Represents which text format to use for websocket transfer. More...
 
enum class  DiscordCoreAPI::TimeFormat : char {
  DiscordCoreAPI::TimeFormat::LongDate = 'D' , DiscordCoreAPI::TimeFormat::LongDateTime = 'F' , DiscordCoreAPI::TimeFormat::LongTime = 'T' , DiscordCoreAPI::TimeFormat::ShortDate = 'd' ,
  DiscordCoreAPI::TimeFormat::ShortDateTime = 'f' , DiscordCoreAPI::TimeFormat::ShortTime = 't'
}
 Time formatting methods. More...
 
enum class  DiscordCoreAPI::UpdatePresenceStatusTypes {
  DiscordCoreAPI::UpdatePresenceStatusTypes::online = 0 , DiscordCoreAPI::UpdatePresenceStatusTypes::dnd = 1 , DiscordCoreAPI::UpdatePresenceStatusTypes::idle = 2 , DiscordCoreAPI::UpdatePresenceStatusTypes::invisible = 3 ,
  DiscordCoreAPI::UpdatePresenceStatusTypes::offline = 4
}
 Update-presence status types. More...
 

Functions

DiscordCoreAPI_Dll std::string DiscordCoreAPI::getTimeAndDate ()
 Acquires a timeStamp with the current time and date - suitable for use in message-embeds.
 
template<typename RTy >
auto DiscordCoreAPI::NewThreadAwaitable ()
 An awaitable that can be used to launch the CoRoutine onto a new thread - as well as return the handle for stoppping its execution.
 
DiscordCoreAPI_Dll void DiscordCoreAPI::reportException (const std::string &currentFunctionName, std::source_location location=std::source_location::current())
 Prints the current file, line, and column from which the function is being called - typically from within an exception's "catch" block.
 

Variables

const std::string DiscordCoreAPI::Colors::Aquamarine = "7FFFD4"
 Aquamarine.
 
const std::string DiscordCoreAPI::Colors::Bismark = "546E7A"
 Bismark.
 
const std::string DiscordCoreAPI::Colors::Black = "000000"
 Black.
 
const std::string DiscordCoreAPI::Colors::Blue = "0000FF"
 Blue.
 
const std::string DiscordCoreAPI::Colors::BlueAquamarine = "607D8B"
 Blue aquamarine.
 
const std::string DiscordCoreAPI::Colors::BlueGreen = "088F8F"
 Blue green.
 
const std::string DiscordCoreAPI::Colors::Brown = "992D22"
 Brown.
 
const std::string DiscordCoreAPI::Colors::CadmiumGreen = "097969"
 Cadmium green.
 
const std::string DiscordCoreAPI::Colors::Cinnabar = "E74C3C"
 Cinnabar.
 
const std::string DiscordCoreAPI::Colors::Cyan = "00FFFF"
 Cyan.
 
const std::string DiscordCoreAPI::Colors::DarkGoldenrod = "C27C0E"
 Dark goldenrod.
 
const std::string DiscordCoreAPI::Colors::DarkGray = "404040"
 Dark gray.
 
const std::string DiscordCoreAPI::Colors::DeepLilac = "9B59B6"
 Deep lilac.
 
const std::string DiscordCoreAPI::Colors::DeepSea = "11806A"
 Deep sea.
 
const std::string DiscordCoreAPI::Colors::DiscordBlack = "000001"
 Discord black.
 
const std::string DiscordCoreAPI::Colors::DiscordWhite = "FFFFFE"
 Discord white.
 
const std::string DiscordCoreAPI::Colors::Endeavour = "206694"
 Endeavor.
 
const std::string DiscordCoreAPI::Colors::ForestGreen = "228B22"
 Forest green.
 
const std::string DiscordCoreAPI::Colors::Gray = "808080"
 Gray.
 
const std::string DiscordCoreAPI::Colors::GrayChateau = "979C9F"
 Gray chateau.
 
const std::string DiscordCoreAPI::Colors::Green = "00FF00"
 Green.
 
const std::string DiscordCoreAPI::Colors::JazzberryJam = "AD1457"
 Jazzberry jam.
 
const std::string DiscordCoreAPI::Colors::LightGray = "C0C0C0"
 Light gray.
 
const std::string DiscordCoreAPI::Colors::LightSeaGreen = "1ABC9C"
 Light sea green.
 
const std::string DiscordCoreAPI::Colors::Lime = "00FF00"
 Lime.
 
const std::string DiscordCoreAPI::Colors::Magenta = "FF00FF"
 Magenta.
 
const std::string DiscordCoreAPI::Colors::MediumSeaGreen = "2ECC71"
 Medium sea green.
 
const std::string DiscordCoreAPI::Colors::MoonYellow = "F1C40F"
 Moon yellow.
 
const std::string DiscordCoreAPI::Colors::Orange = "FFC800"
 Orange.
 
const std::string DiscordCoreAPI::Colors::Pink = "FFAFAF"
 Pink.
 
const std::string DiscordCoreAPI::Colors::RalliArtCrimson = "E60012"
 Ralliart crimson.
 
const std::string DiscordCoreAPI::Colors::Raspberry = "E30B5C"
 Raspberry.
 
const std::string DiscordCoreAPI::Colors::Red = "FF0000"
 Red.
 
const std::string DiscordCoreAPI::Colors::Ruby = "E91E63"
 Ruby.
 
const std::string DiscordCoreAPI::Colors::Rust = "A84300"
 Rust.
 
const std::string DiscordCoreAPI::Colors::ScarletRed = "FF2400"
 Scarlet red.
 
const std::string DiscordCoreAPI::Colors::SeaGreen = "1F8B4C"
 Sea green.
 
const std::string DiscordCoreAPI::Colors::StiBlue = "0E4BEF"
 Sti blue.
 
const std::string DiscordCoreAPI::Colors::Submarine = "95A5A6"
 Submarine.
 
const std::string DiscordCoreAPI::Colors::SummerSky = "3498DB"
 Summer skye.
 
const std::string DiscordCoreAPI::Colors::TahitiGold = "E67E22"
 Tahiti gold.
 
const std::string DiscordCoreAPI::Colors::VividViolet = "71368A"
 Vivid violet.
 
const std::string DiscordCoreAPI::Colors::White = "FFFFFF"
 White.
 
const std::string DiscordCoreAPI::Colors::WrxBlue = "00247D"
 Wrx blue.
 
const std::string DiscordCoreAPI::Colors::Yellow = "FFFF00"
 Yellow.