Skip to content

Commit 252356b

Browse files
authored
Merge pull request #574 from underctrl-io/label-and-poll
feat: label and poll jsx components
2 parents 605a8e7 + 5e4d235 commit 252356b

File tree

162 files changed

+1245
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+1245
-197
lines changed

apps/test-bot/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@types/ms": "^2.1.0",
29+
"cross-env": "^10.1.0",
2930
"tsx": "^4.7.0"
3031
}
3132
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
Poll,
3+
PollQuestion,
4+
PollAnswer,
5+
CommandData,
6+
ChatInputCommand,
7+
} from 'commandkit';
8+
import { PollData } from 'discord.js';
9+
10+
export const command: CommandData = {
11+
name: 'poll',
12+
description: 'Create a poll',
13+
};
14+
15+
export const chatInput: ChatInputCommand = async (ctx) => {
16+
const poll: PollData = (
17+
<Poll>
18+
<PollQuestion>What's your favorite color?</PollQuestion>
19+
<PollAnswer emoji="🟥">Red</PollAnswer>
20+
<PollAnswer emoji="🟦">Blue</PollAnswer>
21+
<PollAnswer emoji="🟩">Green</PollAnswer>
22+
<PollAnswer>Other</PollAnswer>
23+
</Poll>
24+
);
25+
26+
await ctx.interaction.reply({ poll });
27+
};

apps/test-bot/src/app/commands/(interactions)/+middleware.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { MessageFlags } from 'discord.js';
44
export function beforeExecute(ctx: MiddlewareContext) {
55
Logger.info('Pre-command middleware');
66

7-
console.log({ isAI: ctx.ai });
8-
97
const user = ctx.isInteraction() ? ctx.interaction.user : ctx.message.author;
108

119
if (ctx.commandName === 'prompt' && user.id === '159985870458322944') {

apps/test-bot/src/app/commands/(interactions)/prompt.tsx

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import {
33
Modal,
44
ShortInput,
55
ParagraphInput,
6+
Label,
67
OnModalKitSubmit,
78
MessageCommandContext,
89
ChatInputCommandContext,
10+
StringSelectMenu,
11+
StringSelectMenuOption,
912
} from 'commandkit';
10-
import { MessageFlags } from 'discord.js';
13+
import { ComponentType, MessageFlags } from 'discord.js';
1114

1215
export const command: CommandData = {
1316
name: 'prompt',
@@ -17,9 +20,10 @@ export const command: CommandData = {
1720
const handleSubmit: OnModalKitSubmit = async (interaction, context) => {
1821
const name = interaction.fields.getTextInputValue('name');
1922
const description = interaction.fields.getTextInputValue('description');
23+
const select = interaction.fields.getField('select');
2024

2125
await interaction.reply({
22-
content: `Name: ${name}\nDescription: ${description}`,
26+
content: `Name: ${name}\nDescription: ${description}\nSelect: ${select}`,
2327
flags: MessageFlags.Ephemeral,
2428
});
2529

@@ -28,13 +32,38 @@ const handleSubmit: OnModalKitSubmit = async (interaction, context) => {
2832

2933
export async function chatInput(ctx: ChatInputCommandContext) {
3034
const modal = (
31-
<Modal title={'Modal'} onSubmit={handleSubmit}>
32-
<ShortInput customId="name" label="Name" placeholder="John" required />
33-
<ParagraphInput
34-
customId="description"
35-
label={'Description'}
36-
placeholder={'Enter a description here...'}
37-
/>
35+
<Modal title="Modal" onSubmit={handleSubmit}>
36+
<Label label="Name" description="Enter your name">
37+
<ShortInput customId="name" placeholder="John Doe" required />
38+
</Label>
39+
<Label label="Description" description="Enter a description here...">
40+
<ParagraphInput
41+
customId="description"
42+
placeholder="Lorem ipsum dolor sit amet..."
43+
/>
44+
</Label>
45+
<Label label="Select" description="Select an option">
46+
<StringSelectMenu customId="select">
47+
<StringSelectMenuOption
48+
label="Option 1"
49+
value="option1"
50+
description="This is the first option"
51+
emoji="👍"
52+
/>
53+
<StringSelectMenuOption
54+
label="Option 2"
55+
value="option2"
56+
description="This is the second option"
57+
emoji="👍"
58+
/>
59+
<StringSelectMenuOption
60+
label="Option 3"
61+
value="option3"
62+
description="This is the third option"
63+
emoji="👍"
64+
/>
65+
</StringSelectMenu>
66+
</Label>
3867
</Modal>
3968
);
4069

apps/website/docs/api-reference/commandkit/classes/button-kit.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
1313

1414
## ButtonKit
1515

16-
<GenerationInfo sourceFile="packages/commandkit/src/components/v1/button/ButtonKit.ts" sourceLine="64" packageName="commandkit" />
16+
<GenerationInfo sourceFile="packages/commandkit/src/components/interactive/button/ButtonKit.ts" sourceLine="64" packageName="commandkit" />
1717

1818
A builder for creating buttons with additional features like interaction collectors and event handling.
1919

apps/website/docs/api-reference/commandkit/classes/channel-select-menu-kit.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
1313

1414
## ChannelSelectMenuKit
1515

16-
<GenerationInfo sourceFile="packages/commandkit/src/components/v1/select-menu/ChannelSelectMenuKit.ts" sourceLine="40" packageName="commandkit" />
16+
<GenerationInfo sourceFile="packages/commandkit/src/components/interactive/select-menu/ChannelSelectMenuKit.ts" sourceLine="40" packageName="commandkit" />
1717

1818
A builder for creating channel select menus with additional features like interaction collectors and event handling.
1919
This class extends the ChannelSelectMenuBuilder from discord.js and adds methods for handling interactions.

apps/website/docs/api-reference/commandkit/classes/mentionable-select-menu-kit.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
1313

1414
## MentionableSelectMenuKit
1515

16-
<GenerationInfo sourceFile="packages/commandkit/src/components/v1/select-menu/MentionableSelectMenuKit.ts" sourceLine="35" packageName="commandkit" />
16+
<GenerationInfo sourceFile="packages/commandkit/src/components/interactive/select-menu/MentionableSelectMenuKit.ts" sourceLine="35" packageName="commandkit" />
1717

1818

1919

apps/website/docs/api-reference/commandkit/classes/modal-kit.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
1313

1414
## ModalKit
1515

16-
<GenerationInfo sourceFile="packages/commandkit/src/components/v1/modal/ModalKit.ts" sourceLine="65" packageName="commandkit" />
16+
<GenerationInfo sourceFile="packages/commandkit/src/components/interactive/modal/ModalKit.ts" sourceLine="65" packageName="commandkit" />
1717

1818
A builder for creating modals with additional features like interaction collectors and event handling.
1919
This class extends the ModalBuilder from discord.js and adds methods for handling interactions.

apps/website/docs/api-reference/commandkit/classes/role-select-menu-kit.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
1313

1414
## RoleSelectMenuKit
1515

16-
<GenerationInfo sourceFile="packages/commandkit/src/components/v1/select-menu/RoleSelectMenuKit.ts" sourceLine="40" packageName="commandkit" />
16+
<GenerationInfo sourceFile="packages/commandkit/src/components/interactive/select-menu/RoleSelectMenuKit.ts" sourceLine="40" packageName="commandkit" />
1717

1818
A builder for creating role select menus with additional features like interaction collectors and event handling.
1919
This class extends the RoleSelectMenuBuilder from discord.js and adds methods for handling interactions.

apps/website/docs/api-reference/commandkit/classes/string-select-menu-kit.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
1313

1414
## StringSelectMenuKit
1515

16-
<GenerationInfo sourceFile="packages/commandkit/src/components/v1/select-menu/StringSelectMenuKit.ts" sourceLine="40" packageName="commandkit" />
16+
<GenerationInfo sourceFile="packages/commandkit/src/components/interactive/select-menu/StringSelectMenuKit.ts" sourceLine="40" packageName="commandkit" />
1717

1818
A builder for creating string select menus with additional features like interaction collectors and event handling.
1919
This class extends the StringSelectMenuBuilder from discord.js and adds methods for handling interactions.

0 commit comments

Comments
 (0)