diff options
author | Cara Salter <cara@devcara.com> | 2023-06-10 00:06:07 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2023-06-10 00:06:07 -0400 |
commit | 6136631d2dcd9b1f561fa589acabcda7de8e2f36 (patch) | |
tree | f52b1afe5bdceff29bc11015c3f00b54d4bd4b76 /modules/mail | |
parent | e09e7825369ec8217456065d31dbbbb992b7f1bb (diff) | |
download | 142bot-6136631d2dcd9b1f561fa589acabcda7de8e2f36.tar.gz 142bot-6136631d2dcd9b1f561fa589acabcda7de8e2f36.zip |
mail: Init mail module
Also bind the slash command and form submit events properly
Change-Id: I8d01cb0075945c79c6bf991fa4d64f5227dd5f86
Diffstat (limited to 'modules/mail')
-rw-r--r-- | modules/mail/mail.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
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 <dpp/dpp.h> + +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) |