aboutsummaryrefslogtreecommitdiff
path: root/examples/discord-interactions/commands/modal.ts
diff options
context:
space:
mode:
authorGravatar evanwashere <github@evan.lol> 2022-07-05 12:16:52 -0400
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-07-05 09:26:58 -0700
commitd3e0955ddca23bd320a7fd4afc1e1b313dc0db04 (patch)
treef762cdd39122d02b8332dffb8241436ecdcc6313 /examples/discord-interactions/commands/modal.ts
parent5d4fbf7f020ed7134b4f447a8119e5a3718fcbb0 (diff)
downloadbun-d3e0955ddca23bd320a7fd4afc1e1b313dc0db04.tar.gz
bun-d3e0955ddca23bd320a7fd4afc1e1b313dc0db04.tar.zst
bun-d3e0955ddca23bd320a7fd4afc1e1b313dc0db04.zip
more examples
Diffstat (limited to 'examples/discord-interactions/commands/modal.ts')
-rw-r--r--examples/discord-interactions/commands/modal.ts51
1 files changed, 51 insertions, 0 deletions
diff --git a/examples/discord-interactions/commands/modal.ts b/examples/discord-interactions/commands/modal.ts
new file mode 100644
index 000000000..ed4026ee0
--- /dev/null
+++ b/examples/discord-interactions/commands/modal.ts
@@ -0,0 +1,51 @@
+import { SlashCommand, ComponentType, TextInputStyle } from 'slash-create';
+
+export default class ModalCommand extends SlashCommand {
+ constructor(creator) {
+ super(creator, {
+ name: 'modal',
+ description: 'Send a cool modal.'
+ });
+
+ this.filePath = __filename;
+ }
+
+ async run(ctx) {
+ // You can send a modal this way
+ // Keep in mind providing a callback is optional, but no callback requires the custom_id to be defined.
+ ctx.sendModal(
+ {
+ title: 'Example Modal',
+ components: [
+ {
+ type: ComponentType.ACTION_ROW,
+ components: [
+ {
+ type: ComponentType.TEXT_INPUT,
+ label: 'Text Input',
+ style: TextInputStyle.SHORT,
+ custom_id: 'text_input',
+ placeholder: 'Type something...'
+ }
+ ]
+ },
+ {
+ type: ComponentType.ACTION_ROW,
+ components: [
+ {
+ type: ComponentType.TEXT_INPUT,
+ label: 'Long Text Input',
+ style: TextInputStyle.PARAGRAPH,
+ custom_id: 'long_text_input',
+ placeholder: 'Type something...'
+ }
+ ]
+ }
+ ]
+ },
+ (mctx) => {
+ mctx.send(`Your input: ${mctx.values.text_input}\nYour long input: ${mctx.values.long_text_input}`);
+ }
+ );
+ }
+} \ No newline at end of file