-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstateful-modal.ts
34 lines (32 loc) · 1.14 KB
/
stateful-modal.ts
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
import { ComponentType, TextInputStyle } from '@discordjs/core';
import { Modal } from '/components/types.js';
import { mapModalTextInputValues } from '/utils/interactions.js';
import { createStatefulInteraction } from '/utils/stateful.js';
export const exampleStatefulModal = createStatefulInteraction<Modal>({
data: {
custom_id: 'send_user_message',
title: 'Send message to user',
components: [
{
type: ComponentType.ActionRow,
components: [
{
type: ComponentType.TextInput,
custom_id: 'message',
label: 'Message',
style: TextInputStyle.Short,
required: true,
},
],
},
],
},
async execute({ data: interaction, api, state }) {
const { message } = mapModalTextInputValues(interaction.data) as {
message: string;
};
await api.interactions.reply(interaction.id, interaction.token, {
content: `<@${state}>, ${message}`,
});
},
});