64 class sigtermerror :
public dca_exception {
66 inline sigtermerror(jsonifier::string_view message, std::source_location location = std::source_location::current()) :
dca_exception{ message, location } {};
69 class sigsegverror :
public dca_exception {
71 inline sigsegverror(jsonifier::string_view message, std::source_location location = std::source_location::current()) :
dca_exception{ message, location } {};
74 class siginterror :
public dca_exception {
76 inline siginterror(jsonifier::string_view message, std::source_location location = std::source_location::current()) :
dca_exception{ message, location } {};
79 class sigillerror :
public dca_exception {
81 inline sigillerror(jsonifier::string_view message, std::source_location location = std::source_location::current()) :
dca_exception{ message, location } {};
84 class sigabrterror :
public dca_exception {
86 inline sigabrterror(jsonifier::string_view message, std::source_location location = std::source_location::current()) :
dca_exception{ message, location } {};
89 class sigfpeerror :
public dca_exception {
91 inline sigfpeerror(jsonifier::string_view message, std::source_location location = std::source_location::current()) :
dca_exception{ message, location } {};
94 using sound_cloud_apimap = unordered_map<uint64_t, unique_ptr<discord_core_internal::sound_cloud_api>>;
96 using you_tube_apimap = unordered_map<uint64_t, unique_ptr<discord_core_internal::you_tube_api>>;
98 using voice_connections_map = unordered_map<uint64_t, unique_ptr<voice_connection>>;
100 using song_apimap = unordered_map<uint64_t, unique_ptr<song_api>>;
102 template<
typename... arg_types>
using time_elapsed_handler = std::function<void(arg_types...)>;
104 template<
typename... arg_types>
105 inline static co_routine<void, false> threadFunction(time_elapsed_handler<arg_types...> timeElapsedHandler,
bool repeated, int64_t timeInterval, arg_types... args) {
106 auto threadHandle =
co_await newThreadAwaitable<void, false>();
107 stop_watch<milliseconds> stopWatch{ milliseconds{ timeInterval } };
110 std::this_thread::sleep_for(milliseconds{
static_cast<int64_t
>(std::ceil(
static_cast<float>(timeInterval) * 10.0f / 100.0f)) });
111 while (!stopWatch.hasTimeElapsed() && !threadHandle.promise().stopRequested()) {
112 std::this_thread::sleep_for(1ms);
115 if (threadHandle.promise().stopRequested()) {
119 timeElapsedHandler(args...);
120 }
catch (
const dca_exception& error) {
121 message_printer::printError<print_message_type::general>(error.what());
123 if (threadHandle.promise().stopRequested()) {
126 std::this_thread::sleep_for(1ms);
131 template<
typename... arg_types>
inline static void executeFunctionAfterTimePeriod(time_elapsed_handler<arg_types...> timeElapsedHandler, int64_t timeDelay,
bool repeated,
132 bool blockForCompletion, arg_types... args) {
133 auto newThread = threadFunction<arg_types...>(timeElapsedHandler, repeated, timeDelay, args...);
134 if (blockForCompletion) {
147 friend class discord_core_internal::base_socket_agent;
148 friend class discord_core_internal::websocket_core;
154 static discord_core_internal::sound_cloud_api& getSoundCloudAPI(
snowflake guildId);
156 static discord_core_internal::you_tube_api& getYouTubeAPI(
snowflake guildId);
175 bool alwaysRegister =
false);
183 const config_manager& getConfigManager()
const;
191 milliseconds getTotalUpTime();
212 unordered_map<uint64_t, unique_ptr<discord_core_internal::base_socket_agent>> baseSocketAgentsMap{};
213 std::deque<create_application_command_data> commandsToRegister{};
215 stop_watch<milliseconds> connectionStopWatch01{ 5000ms };
217 discord_core_internal::wsadata_wrapper theWSAData{};
219 std::atomic_uint64_t currentlyConnectingShard{};
220 std::atomic_bool areWeReadyToConnect{
false };
222 milliseconds startupTimeSinceEpoch{};
223 config_manager configManager{};
226 bool areWeFullyConnected();
228 void registerFunctionsInternal();
232 bool instantiateWebSockets();
A type of user_data, to represent the bot and some of its associated endpoints.
return_type get()
Gets the resulting value of the co_routine.
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.
Class for handling the assignment of event-handling functions.int32_t.
A discord guild. used to connect to/disconnect from voice.
An interface class for the guild_data related discord endpoints.
A class representing a snowflake identifier with various operations.
A class representing the song apis.
A smart pointer class that provides unique ownership semantics.
voice_connection class - represents the connection to a given voice channel_data.
The main namespace for the forward-facing interfaces.
For creating an application command.
dca_exception(jsonifier::string_view error, std::source_location location=std::source_location::current())
Constructor to create a dca_exception with an error message and optional source location.
Configuration data for the library's main class, discord_core_client.
Data from the get_gateway_bot endpoint.