Skip to content

quarzasiphix/discord-cpp-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discord bot library in c++

(currently broken)

Early build, made entirely from scratch using sockets and curl

Libraries used:


How to use

  • i highly advise to compile boost and curl manually to avoid issues

  • Currently only supports release x64 and uses std c++ 20. support for other releases will be added in future versions
  • precompiled X64, release libraries of Boost and Curl are already included in the project files discord++/libs

my example:

#include "../discord++/discord++.hpp"

using namespace Discord;

void on_login(client client)
{
	std::cout << "welcome " + client.username + "#" + client.discriminator << std::endl;
}

void on_invalid(discord* _discord)
{
	std::cout << "invalid token";
	std::cin.get();
}

void on_msg(client::message msg)
{

	msg.command("test", [](client::message msg) {
		msg.respond(&msg, "received test");
		std::cout << "received test" << std::endl;
	});

	msg.command("pong", [](client::message msg) {
		msg.respond(&msg, "ping");
		std::cout << "received pong" << std::endl;
	});

	msg.command("ping", [](client::message msg) {
		msg.respond(&msg, "pong");
		std::cout << "received ping" << std::endl;
	});

	msg.command("user", [](client::message msg) {
		discord disc;
		if (disc.get_user(msg.param[1]))
			msg.respond(&msg, std::string("```"
				"name: " + disc.fetched.username + "#" + disc.fetched.discriminator + "\n" +
				"id: " + disc.fetched.id + "\n" + "```" +
				disc.fetched.profile_url + "\n"
			));
		else msg.respond(&msg, "```invalid id```");
	});
}

int main()
{
	const char* sbtoken = "token";

	discord sbot;
	sbot.start(sbtoken, false, on_invalid, on_msg, on_login);

	std::cout << "press enter to stop client" << std::endl;
	std::cin.get();
}

About

c++ discord bot base built from scratch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published