49 lines
931 B
C++
49 lines
931 B
C++
#pragma once
|
|
#include <dpp/dpp.h>
|
|
#include <functional>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <uv.h>
|
|
#include <queue>
|
|
|
|
enum class BotCommandType {
|
|
SHORTEN
|
|
};
|
|
|
|
struct ShortenCommand {
|
|
std::string url;
|
|
dpp::slashcommand_t event;
|
|
};
|
|
|
|
struct BotCommand {
|
|
BotCommand(ShortenCommand&&);
|
|
BotCommand(BotCommand&&);
|
|
~BotCommand();
|
|
|
|
BotCommandType type;
|
|
union {
|
|
ShortenCommand shortenCmd;
|
|
};
|
|
};
|
|
|
|
class DiscordClient {
|
|
public:
|
|
DiscordClient(uv_loop_t *loop, std::string token);
|
|
~DiscordClient();
|
|
bool start();
|
|
bool stop();
|
|
|
|
std::function<void(std::string&, dpp::slashcommand_t&)> on_shorten_command;
|
|
private:
|
|
static void uv_callback(uv_async_t *h);
|
|
|
|
bool m_running = false;
|
|
uv_loop_t *m_eventLoop;
|
|
uv_async_t *m_eventHandle = nullptr;
|
|
std::unique_ptr<dpp::cluster> m_bot;
|
|
std::queue<BotCommand> m_commandQueue;
|
|
std::mutex m_commandQueueMutex;
|
|
std::string m_botToken;
|
|
};
|