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