From 6136631d2dcd9b1f561fa589acabcda7de8e2f36 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Sat, 10 Jun 2023 00:06:07 -0400 Subject: mail: Init mail module Also bind the slash command and form submit events properly Change-Id: I8d01cb0075945c79c6bf991fa4d64f5227dd5f86 --- modules/mail/mail.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 modules/mail/mail.cpp (limited to 'modules/mail') diff --git a/modules/mail/mail.cpp b/modules/mail/mail.cpp new file mode 100644 index 0000000..9ec170a --- /dev/null +++ b/modules/mail/mail.cpp @@ -0,0 +1,52 @@ +#include <142bot/modules.hpp> +#include <142bot/util.hpp> +#include + +class MailModule: public Module { + public: + MailModule(Bot* creator, ModuleLoader* ml) : Module(creator, ml) { + ml->attach({I_OnSlashCommand, I_OnFormSubmit}, this); + auto id = creator->cfg.value("application_id", ""); + creator->core->log(dpp::ll_info, "Application ID: " + id); + creator->core->guild_command_create(dpp::slashcommand("mailalert", "Alert a resident that they have mail", id), creator->cfg["main_guild"]); + creator->core->log(dpp::ll_info, "Registered mailalert"); + } + + virtual std::string version() { + return "0.1.0"; + } + + virtual std::string description() { + return "Alerts residents when mail has arrived"; + } + + bool OnSlashCommand(const dpp::slashcommand_t &event) { + if (event.command.get_command_name() == "mailalert") { + dpp::interaction_modal_response dialog("mail", "Mail alert!"); + + dialog.add_component( + dpp::component() + .set_label("Sender") + .set_type(dpp::component_type::cot_text) + .set_id("sender") + .set_placeholder("Boom boom") + .set_text_style(dpp::text_style_type::text_short) + ); + + auto select_comp = dialog.add_component( + dpp::component() + .set_label("Recipient") + .set_id("recipient") + .set_type(dpp::component_type::cot_mentionable_selectmenu) + ); + } + return true; + } + + bool OnFormSubmit(const dpp::form_submit_t &event) { + + return true; + } +}; + +ENTRYPOINT(MailModule) -- cgit v1.2.3