65 lines
1.8 KiB
C++
65 lines
1.8 KiB
C++
#ifndef API_EMBED_HPP_
|
|
#define API_EMBED_HPP_
|
|
#include <utils/json.hpp>
|
|
#include <string>
|
|
#include <exception>
|
|
#include <iostream>
|
|
using std::string;
|
|
using std::cout;
|
|
using std::endl;
|
|
using json = nlohmann::json;
|
|
class EmbedBuilder {
|
|
private:
|
|
json embed = {
|
|
{"content", ""},
|
|
{"tts", false},
|
|
{"embeds", json::array()}
|
|
}, data;
|
|
public:
|
|
EmbedBuilder(const json& data) : data(data) {
|
|
embed = {
|
|
{"content", ""},
|
|
{"tts", false},
|
|
{"embeds", json::array()}
|
|
};
|
|
}
|
|
EmbedBuilder& addTitle(const string& title) {
|
|
if (embed["embeds"].size() == 0) {
|
|
embed["embeds"].push_back(json::object());
|
|
}
|
|
embed["embeds"].back()["title"] = title;
|
|
return *this;
|
|
}
|
|
EmbedBuilder& addDescription(const string& desc) {
|
|
if (embed["embeds"].size() == 0) {
|
|
embed["embeds"].push_back(json::object());
|
|
}
|
|
embed["embeds"].back()["description"] = desc;
|
|
return *this;
|
|
}
|
|
EmbedBuilder& addColor(const string& color) {
|
|
if (embed["embeds"].size() == 0) {
|
|
embed["embeds"].push_back(json::object());
|
|
}
|
|
embed["embeds"].back()["color"] = color;
|
|
return *this;
|
|
}
|
|
EmbedBuilder& addUrl(const string& url) {
|
|
if (embed["embeds"].size() == 0) {
|
|
embed["embeds"].push_back(json::object());
|
|
}
|
|
embed["embeds"].back()["url"] = url;
|
|
return *this;
|
|
}
|
|
EmbedBuilder& addImage(const string& imageurl) {
|
|
if (embed["embeds"].size() == 0) {
|
|
embed["embeds"].push_back(json::object());
|
|
}
|
|
embed["embeds"].back()["image"] = { {"url", imageurl} };
|
|
return *this;
|
|
}
|
|
json getEmbed() const {
|
|
return embed;
|
|
}
|
|
};
|
|
#endif |