-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathmodal_example.js
56 lines (53 loc) · 1.09 KB
/
modal_example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const express = require('express');
const {
InteractionType,
InteractionResponseType,
verifyKeyMiddleware,
} = require('../dist');
const app = express();
app.post(
'/interactions',
verifyKeyMiddleware(process.env.CLIENT_PUBLIC_KEY),
(req, res) => {
const interaction = req.body;
if (interaction.type === InteractionType.APPLICATION_COMMAND) {
res.send({
type: InteractionResponseType.APPLICATION_MODAL,
data: {
title: 'Test',
custom_id: 'test-modal',
components: [
{
type: 1,
components: [
{
type: 4,
style: 1,
label: 'Short Input',
custom_id: 'short-input',
placeholder: 'Short Input',
},
],
},
{
type: 1,
components: [
{
type: 4,
style: 1,
label: 'Paragraph Input',
custom_id: 'paragraph-input',
placeholder: 'Paragraph Input',
required: false,
},
],
},
],
},
});
}
},
);
app.listen(8999, () => {
console.log('Example app listening at http://localhost:8999');
});