@@ -10,10 +10,17 @@ import type {
1010 GuildMember ,
1111 APIInteractionDataResolvedGuildMember ,
1212 Attachment ,
13- AutocompleteInteraction
13+ AutocompleteInteraction ,
14+ Message ,
15+ GuildEmoji ,
16+ PartialEmoji ,
17+ RestOrArray ,
18+ APIApplicationCommandOptionChoice ,
19+ ChannelType
1420} from 'discord.js'
21+ import type { URL } from 'node:url'
1522
16- type OptionType =
23+ export type OptionType =
1724 | 'String'
1825 | 'Integer'
1926 | 'Boolean'
@@ -24,6 +31,10 @@ type OptionType =
2431 | 'Mentionable'
2532 | 'Attachment'
2633 | 'SubCommand'
34+ | 'Message'
35+ | 'Emoji'
36+ | 'Date'
37+ | 'Url'
2738
2839interface _OptionDef < T extends OptionType > {
2940 type : T
@@ -32,24 +43,60 @@ interface _OptionDef<T extends OptionType> {
3243 metadata ?: Record < string , any >
3344}
3445
35- interface _AutocompleteOptionDef {
46+ interface _StringOptionDef {
3647 autocomplete ?: boolean
48+ minLength ?: number
49+ maxLength ?: number
50+ choices ?: RestOrArray < APIApplicationCommandOptionChoice < string > >
51+ }
52+
53+ interface _IntegerOptionDef {
54+ autocomplete ?: boolean
55+ minValue ?: number
56+ maxValue ?: number
57+ choices ?: RestOrArray < APIApplicationCommandOptionChoice < number > >
58+ }
59+
60+ interface _ChannelOptionDef {
61+ types : RestOrArray <
62+ | ChannelType . GuildText
63+ | ChannelType . GuildVoice
64+ | ChannelType . GuildCategory
65+ | ChannelType . GuildAnnouncement
66+ | ChannelType . AnnouncementThread
67+ | ChannelType . PublicThread
68+ | ChannelType . PrivateThread
69+ | ChannelType . GuildStageVoice
70+ | ChannelType . GuildForum
71+ | ChannelType . GuildMedia
72+ >
73+ }
74+
75+ interface _NumberOptionDef {
76+ autocomplete ?: boolean
77+ minValue ?: number
78+ maxValue ?: number
79+ choices ?: RestOrArray < APIApplicationCommandOptionChoice < number > >
3780}
3881
3982interface _SubCommandOptionDef {
4083 options ?: Record < string , Exclude < OptionDef , SubCommandOptionDef > >
4184}
4285
43- type StringOptionDef = _OptionDef < 'String' > & _AutocompleteOptionDef
44- type IntegerOptionDef = _OptionDef < 'Integer' > & _AutocompleteOptionDef
86+ type StringOptionDef = _OptionDef < 'String' > & _StringOptionDef
87+ type IntegerOptionDef = _OptionDef < 'Integer' > & _IntegerOptionDef
4588type BooleanOptionDef = _OptionDef < 'Boolean' >
4689type UserOptionDef = _OptionDef < 'User' >
47- type ChannelOptionDef = _OptionDef < 'Channel' >
90+ type ChannelOptionDef = _OptionDef < 'Channel' > & _ChannelOptionDef
4891type RoleOptionDef = _OptionDef < 'Role' >
49- type NumberOptionDef = _OptionDef < 'Number' > & _AutocompleteOptionDef
92+ type NumberOptionDef = _OptionDef < 'Number' > & _NumberOptionDef
5093type MentionableOptionDef = _OptionDef < 'Mentionable' >
5194type AttachmentOptionDef = _OptionDef < 'Attachment' >
5295type SubCommandOptionDef = _OptionDef < 'SubCommand' > & _SubCommandOptionDef
96+ type MessageOptionDef = _OptionDef < 'Message' > & _StringOptionDef
97+ type EmojiOptionDef = _OptionDef < 'Emoji' > & _StringOptionDef
98+ type DateOptionDef = _OptionDef < 'Date' > & _StringOptionDef
99+ type UrlOptionDef = _OptionDef < 'Url' > & _StringOptionDef
53100
54101type OptionDef =
55102 | StringOptionDef
@@ -62,6 +109,10 @@ type OptionDef =
62109 | MentionableOptionDef
63110 | AttachmentOptionDef
64111 | SubCommandOptionDef
112+ | MessageOptionDef
113+ | EmojiOptionDef
114+ | DateOptionDef
115+ | UrlOptionDef
65116
66117export type OptionsDef = Record < string , OptionDef >
67118
@@ -77,6 +128,11 @@ export type ParsedOptionType =
77128 | GuildMember
78129 | APIInteractionDataResolvedGuildMember
79130 | Attachment
131+ | Message
132+ | GuildEmoji
133+ | PartialEmoji
134+ | Date
135+ | URL
80136 | null
81137
82138export type ParsedOptions < T extends OptionsDef = OptionsDef > = Record <
@@ -178,6 +234,46 @@ export type ParsedOptions<T extends OptionsDef = OptionsDef> = Record<
178234 : never
179235 } [ keyof T ] ,
180236 boolean | null
237+ > &
238+ Record <
239+ {
240+ [ K in keyof T ] : T [ K ] extends {
241+ type : 'Message'
242+ }
243+ ? K
244+ : never
245+ } [ keyof T ] ,
246+ Message | null
247+ > &
248+ Record <
249+ {
250+ [ K in keyof T ] : T [ K ] extends {
251+ type : 'Emoji'
252+ }
253+ ? K
254+ : never
255+ } [ keyof T ] ,
256+ GuildEmoji | PartialEmoji | null
257+ > &
258+ Record <
259+ {
260+ [ K in keyof T ] : T [ K ] extends {
261+ type : 'Date'
262+ }
263+ ? K
264+ : never
265+ } [ keyof T ] ,
266+ Date | null
267+ > &
268+ Record <
269+ {
270+ [ K in keyof T ] : T [ K ] extends {
271+ type : 'Url'
272+ }
273+ ? K
274+ : never
275+ } [ keyof T ] ,
276+ URL | null
181277 >
182278
183279interface CommandContext < T extends OptionsDef = OptionsDef > {
0 commit comments