#include "../bot.hpp" #include "../util.hpp" class Embedmaker { Bot *bot; static inline const std::string& strOrEmpty(const dpp::command_value& v) { if (v.index() == 1) { return std::get(v); } else { static std::string empty; return empty; } } public: Embedmaker(Bot *_bot) : bot(_bot) { bot->cluster.intents |= dpp::intents::i_guild_messages | dpp::intents::i_message_content; bot->add_chatcommand(Bot::ChatCommand({"make_embed", "embed_erstellen"}, "Erstelle ein Embed", dpp::slashcommand() .add_option(dpp::command_option(dpp::command_option_type::co_string, "title", "Titel", true)) .add_option(dpp::command_option(dpp::command_option_type::co_string, "description", "Beschreibung", true)) .add_option(dpp::command_option(dpp::command_option_type::co_string, "image", "Bild", false)) .add_option(dpp::command_option(dpp::command_option_type::co_string, "video", "Video", false)) .add_option(dpp::command_option(dpp::command_option_type::co_string, "thumbnail", "Kleines Bild", false)) .add_option(dpp::command_option(dpp::command_option_type::co_string, "color", "Farbe", false)) .add_option(dpp::command_option(dpp::command_option_type::co_string, "footer_text", "Fußzeilen-Test", false)) .add_option(dpp::command_option(dpp::command_option_type::co_string, "footer_image", "Fußzeilen-Bild", false))), [&](const dpp::slashcommand_t& event) { // Get color unsigned color = Util::str_to_color(strOrEmpty(event.get_parameter("color"))); // Generate embed dpp::embed embed; embed.set_title(strOrEmpty(event.get_parameter("title"))) .set_description(strOrEmpty(event.get_parameter("description"))) .set_image(strOrEmpty(event.get_parameter("image"))) .set_video(strOrEmpty(event.get_parameter("video"))) .set_thumbnail(strOrEmpty(event.get_parameter("thumbnail"))) .set_color(color!=-1?color:0xffffff) .set_footer(strOrEmpty(event.get_parameter("footer_text")), strOrEmpty(event.get_parameter("footer_image"))); // Send embed bot->cluster.message_create(dpp::message().set_channel_id(event.command.channel_id).add_embed(embed)); // Report success event.reply(dpp::message(std::string("Das Embed wurde erstellt!\n") +(color==-1?"**Achtung:** Die Angegebene Farbe wurde nicht erkannt! Versuche es mit einem Farbcode erneut.":"")).set_flags(dpp::message_flags::m_ephemeral)); }); } }; BOT_ADD_MODULE(Embedmaker);