From bc81d3dee7c9958166932f758c1fa81934a89c5f Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Tue, 16 Apr 2024 21:29:28 +0200 Subject: [PATCH] modaltest --- commands/interaction/slash/modal.js | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 commands/interaction/slash/modal.js diff --git a/commands/interaction/slash/modal.js b/commands/interaction/slash/modal.js new file mode 100644 index 0000000..f422dbc --- /dev/null +++ b/commands/interaction/slash/modal.js @@ -0,0 +1,46 @@ +const { Constants } = require('detritus-client'); +const { InteractionCallbackTypes } = Constants; + +const { createEmbed } = require('../../../labscore/utils/embed'); +const { iconPill, codeblock } = require('../../../labscore/utils/markdown'); +const { MessageFlags } = require('detritus-client/lib/constants'); +const { InteractionModal } = require('detritus-client/lib/utils'); + +module.exports = { + description: 'modal command', + name: 'modal', + guildIds: ["1116074561734197270","409840884713127956"], + run: async (context, args) => { + + + const modal = new InteractionModal({ + timeout: 5 * 60 * 1000, // 5 mins, (default is 10 minutes) + title: 'My Cool Questionaire!', + run: (modalContext, args) => { + // args will use the defined customId in the text inputs (args.birds, args.cats) + return modalContext.createMessage(`${args.birds}, ${args.cats}`); + }, + onTimeout: () => { + return context.createMessage('Answer my questions faster next time please'); + }, + }); + + modal.createInputText({ + customId: 'birds', + label: 'Do you like birds?', + maxLength: 120, + minLength: 2, + required: true, + }); + + modal.createInputText({ + customId: 'cats', + label: 'Do you like cats?', + maxLength: 120, + minLength: 2, + required: true, + }); + + return context.respond(modal); + }, +}; \ No newline at end of file