Giter VIP home page Giter VIP logo

discpp's Introduction

DisC++


Simplified, but feature rich Discord API wrapper written in modern C++.

DisC++

DisC++ is a simplified, but feature rich Discord API wrapper written in modern C++. It can run on Linux and Windows. Its also focused on being multi threaded so commands and event listeners are ran on seperate threads, this means you dont have to worry about slowing the bot down with a certain command.

The development branch will have the newest features and might even be faster, or more stable.

State

Library is discontinued. Due to Discord's lack of communication and out-of-touch attitude towards library developers, this library is no longer being maintained. Recommended alternative is DPP.

What makes DisC++ different?

  • Low memory usage.
  • Even though its very memory optimized, it doesn't loose any readability, usability or features.
  • Asynchronous.
  • Built in async command handler.
    • Commands are ran on a separate thread.
    • You can override the built in command handler if you decide to.
  • Built in async event handler and listener.
    • Event listeners are dispatched on separate threads.
    • You can have several event listeners listening for the same event which are all ran on separate threads.
Master Development

Dependencies

Contributing

Please follow Google's styling guide for naming convention.

Information on how to setup a project and how to compile this application will be found in the wiki.

Examples

There may be more inside the Examples folder.

Todo:

  • Finish tons of unimplemented methods in certain classes.
  • Convert the default command handler to use command classes.
  • Convert the event system to use a more object oriented system, similar to the new command handler.
  • Make sure all endpoints are implemented and add them if they aren't.
  • Voice websocket connection.
  • Sending audio through a voice connection.
  • Make the audit log cleaner and easier to use.

Documentation

Currently the only documentation is from Doxygen; its currently completely up to date. You can view it here. If you want to generate documentation you need to install Doxygen and run doxygen in the root DisCPP directory and run the terminal command: doxygen Doxyfile

License

See LICENSE

discpp's People

Contributors

alegoguy253 avatar intexisty avatar seanomik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

discpp's Issues

Internet disconnects cause the library to throw an exception

Whenever my internet disconnects even slightly, My bot throws an exception and the last thing in log is unable to resolve hostname {gateway_url}. I'm curious to whether or not we could allow the library to continue to try to connect to the gateway, discord.NET also has this issue.

Failing to connect to the Discord gateway

It may be due to it trying to validate the cert discord sends. Currently the error it gets is:
Unable to connect to gateway.discord.gg on port 443, error: error in handshake : X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
Find a way to disable validiation in mbedX509

Support API and Gateway v8

  • Gateway Intents are now required (#41)
  • All permissions have been converted to strings-serialized numbers. As such, permissions_new, allow_new, and deny_new have been removed
  • The game field has been removed. If you need a direct replacement, you can instead reference the first element of activities
  • Channel Permission Overwrite types are now numbers (0 and 1) instead of strings ("role" and "member"). However due to a current technical constraint, they are string-serialized numbers in audit log options.
  • embed_enabled and embed_channel_id have been removed. Use widget_enabled and widget_channel_id instead.
  • The Retry-After header is now based in seconds instead of milliseconds (e.g. 123 means 123 seconds)
  • The X-RateLimit-Precision header is no longer respected. X-RateLimit-Reset and X-RateLimit-Reset-After are always returned at millisecond precision (e.g. 123.456 instead of 124)
  • Bots no longer receive Channel Create Gateway Event for DMs
  • delete-message-days is no longer available. Use delete_message_days.
  • Removed roles, premium_since, and nick from Presence Update Gateway Event.
  • Removed some integration object fields for Discord application integrations
  • Removed include_applications from Get Guild Integrations. Application integrations are always included.

The following deprecated routes have been removed for better naming conventions:

  • Removed in favor of /guilds/<guild_id>/widget:
    • /guilds/<guild_id>/embed
  • Removed in favor of /guilds/<guild_id>/widget.json:
    • /servers/<guild_id>/embed.json
    • /servers/<guild_id>/widget.json
    • /guilds/<guild_id>/embed.json
  • Removed in favor of /guilds/<guild_id>/widget.png:
    • /guilds/<guild_id>/embed.png
  • Removed in favor of /channels/<channel_id>/messages/bulk-delete:
    • /channels/<channel_id>/messages/bulk_delete/
  • Removed in favor of /invites/<code>/:
    • /invite/<code>/

After resuming a websocket connection, the bot throws an exception in the heartbeat thread.

I've seen it crash on two separate lines that don't help me at all. The comments will show you what lines.

void Bot::HandleHeartbeat() {
	while (true) {
		nlohmann::json data = { { "op", packet_opcode::heartbeat }, { "d", nullptr } };
		if (last_sequence_number != -1) {
			data["d"] = last_sequence_number;
		}

		logger.Log(LogSeverity::SEV_DEBUG, "Sending heartbeat payload: " + data.dump());
		websocket_outgoing_message msg;
		msg.set_utf8_message(data.dump());
		websocket_client.send(msg);

		heartbeat_acked = false; // Exception here

		logger.Log(LogSeverity::SEV_DEBUG, "Waiting for next heartbeat (" + std::to_string(hello_packet["d"]["heartbeat_interval"].get<int>() / 1000.0 - 10) + " seconds)...");
		// Wait for the required heartbeat interval, while waiting it should be acked from another thread.
		std::this_thread::sleep_for(std::chrono::milliseconds(hello_packet["d"]["heartbeat_interval"].get<int>() - 10));

		if (!heartbeat_acked) {
			logger.Log(LogSeverity::SEV_WARNING, LogTextColor::YELLOW + "Heartbeat wasn't acked, trying to reconnect...");
			disconnected = true;

			ReconnectToWebsocket();
		}
	} // Exception here
}

The method is inside of the source file bot file: https://github.com/SeanOMik/DiscordPP/blob/development/src/bot.cpp#L383

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.