Skip to content

Commit ee9c065

Browse files
committed
test: playground
1 parent 2f5480e commit ee9c065

File tree

7 files changed

+57
-48
lines changed

7 files changed

+57
-48
lines changed

playground/buttons/hello.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineButton } from '../../src'
2+
3+
export default defineButton(
4+
{
5+
label: 'Say hello!',
6+
style: 'Primary'
7+
},
8+
(interaction) => {
9+
interaction.reply('Hello!')
10+
}
11+
)

playground/commands/utils/noop.ts

+6-21
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
1-
import { defineCommand, defineEmbed } from '../../../src'
1+
import { defineCommand, getSelectMenu, useActionRow } from '../../../src'
22

33
export default defineCommand(
44
{
5-
description: 'NOOP!',
6-
options: {
7-
noop: {
8-
type: 'User',
9-
description: 'Noop user',
10-
required: false
11-
}
12-
}
5+
description: 'NOOP!'
136
},
14-
(_, interaction, context) => {
15-
const { noop } = context.options
7+
(_, interaction) => {
8+
const selectMenu = getSelectMenu('choose')
9+
const row = useActionRow(selectMenu!)
1610

17-
const embed = defineEmbed({
18-
color: 0x0099ff,
19-
title: 'Noop title',
20-
description: `Noop description here ${noop}`,
21-
thumbnail:
22-
'https://tr.rbxcdn.com/dd80ef8b8f6ecc3ffd54b4bffbb91af4/420/420/Image/Png',
23-
timestamp: new Date()
24-
})
25-
26-
interaction.reply({ embeds: [embed] })
11+
interaction.reply({ content: 'Say hello:', components: [row] })
2712
}
2813
)

playground/commands/utils/test.ts

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,13 @@
1-
import { TextInputStyle } from 'discord.js'
2-
import { defineCommand, defineModal } from '../../../src'
1+
import { defineCommand, getModal } from '../../../src'
32

43
export default defineCommand(
54
{
65
description: 'Test the bot',
7-
guildOnly: true,
86
preconditions: ['ownerOnly']
97
},
108
async (_, interaction) => {
11-
const modal = defineModal({
12-
id: 'test',
13-
title: 'Test',
14-
textInputs: [
15-
{
16-
id: 'color',
17-
label: 'Color',
18-
style: TextInputStyle.Short,
19-
placeholder: 'Enter a color'
20-
},
21-
{
22-
id: 'hobbies',
23-
label: 'Hobbies',
24-
style: TextInputStyle.Paragraph,
25-
placeholder: 'Enter your hobbies'
26-
}
27-
]
28-
})
9+
const modal = getModal('form')
2910

30-
await interaction.showModal(modal)
11+
await interaction.showModal(modal!)
3112
}
3213
)

playground/events/modals/test.ts

-5
This file was deleted.
File renamed without changes.

playground/modals/form.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { defineModal } from '../../src'
2+
3+
export default defineModal(
4+
{
5+
title: 'Form',
6+
textInputs: [
7+
{
8+
id: 'color',
9+
label: 'Favorite color',
10+
placeholder: 'Enter your favorite color',
11+
style: 'Short'
12+
},
13+
{
14+
id: 'hobbies',
15+
label: 'Hobbies',
16+
placeholder: 'Enter your hobbies',
17+
style: 'Paragraph'
18+
}
19+
]
20+
},
21+
(interaction) => {
22+
const color = interaction.fields.getTextInputValue('color')
23+
24+
interaction.reply(`Submitted color: ${color}`)
25+
}
26+
)

playground/select-menus/choose.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineSelectMenu } from '../../src'
2+
3+
export default defineSelectMenu(
4+
{
5+
type: 'User',
6+
placeholder: 'Choose a user'
7+
},
8+
(interaction) => {
9+
interaction.reply(`You selected an user!`)
10+
}
11+
)

0 commit comments

Comments
 (0)