sparkle/libs/interface/Embed.hpp

58 lines
1.8 KiB
C++
Raw Normal View History

2025-01-29 16:06:47 +05:00
#ifndef INTERFACE_EMBED_HPP_
#define INTERFACE_EMBED_HPP_
2025-01-25 13:22:59 +05:00
#include <includes.hpp>
2024-12-31 02:20:56 +05:00
class EmbedBuilder {
private:
2025-01-25 11:24:56 +05:00
nlohmann::json embed = {
2024-12-31 02:20:56 +05:00
{"content", ""},
{"tts", false},
2025-01-25 11:24:56 +05:00
{"embeds", nlohmann::json::array()}
2024-12-31 02:20:56 +05:00
}, data;
public:
2025-01-25 11:24:56 +05:00
EmbedBuilder(const nlohmann::json& data) : data(data) {
2024-12-31 02:20:56 +05:00
embed = {
{"content", ""},
{"tts", false},
2025-01-25 11:24:56 +05:00
{"embeds", nlohmann::json::array()}
2024-12-31 02:20:56 +05:00
};
}
2025-01-25 11:24:56 +05:00
EmbedBuilder& addTitle(const std::string& title) {
2024-12-31 02:20:56 +05:00
if (embed["embeds"].size() == 0) {
2025-01-25 11:24:56 +05:00
embed["embeds"].emplace_back(nlohmann::json::object());
2024-12-31 02:20:56 +05:00
}
embed["embeds"].back()["title"] = title;
return *this;
}
2025-01-25 11:24:56 +05:00
EmbedBuilder& addDescription(const std::string& desc) {
2024-12-31 02:20:56 +05:00
if (embed["embeds"].size() == 0) {
2025-01-25 11:24:56 +05:00
embed["embeds"].emplace_back(nlohmann::json::object());
2024-12-31 02:20:56 +05:00
}
embed["embeds"].back()["description"] = desc;
return *this;
}
2025-01-25 11:24:56 +05:00
EmbedBuilder& addColor(const std::string& color) {
2024-12-31 02:20:56 +05:00
if (embed["embeds"].size() == 0) {
2025-01-25 11:24:56 +05:00
embed["embeds"].emplace_back(nlohmann::json::object());
2024-12-31 02:20:56 +05:00
}
embed["embeds"].back()["color"] = color;
return *this;
}
2025-01-25 11:24:56 +05:00
EmbedBuilder& addUrl(const std::string& url) {
2024-12-31 02:20:56 +05:00
if (embed["embeds"].size() == 0) {
2025-01-25 11:24:56 +05:00
embed["embeds"].emplace_back(nlohmann::json::object());
2024-12-31 02:20:56 +05:00
}
embed["embeds"].back()["url"] = url;
return *this;
}
2025-01-25 11:24:56 +05:00
EmbedBuilder& addImage(const std::string& imageurl) {
2024-12-31 02:20:56 +05:00
if (embed["embeds"].size() == 0) {
2025-01-25 11:24:56 +05:00
embed["embeds"].emplace_back(nlohmann::json::object());
2024-12-31 02:20:56 +05:00
}
embed["embeds"].back()["image"] = { {"url", imageurl} };
return *this;
}
2025-01-25 11:24:56 +05:00
nlohmann::json getEmbed() const {
2024-12-31 02:20:56 +05:00
return embed;
}
};
#endif