-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: cleanup chat input options (#274)
- Loading branch information
1 parent
bfc5e46
commit 7fe78ce
Showing
53 changed files
with
1,158 additions
and
827 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export interface APIApplicationCommandOptionBase<Type extends ApplicationCommandOptionType> { | ||
type: Type; | ||
name: string; | ||
description: string; | ||
required?: boolean; | ||
} | ||
|
||
export interface APIInteractionDataOptionBase<T extends ApplicationCommandOptionType, D> { | ||
name: string; | ||
type: T; | ||
value: D; | ||
} | ||
|
||
export type APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< | ||
Base extends APIApplicationCommandOptionBase<ApplicationCommandOptionType>, | ||
ChoiceType extends APIApplicationCommandOptionChoice, | ||
> = | ||
| (Base & { | ||
autocomplete: true; | ||
}) | ||
| (Base & { | ||
autocomplete?: false; | ||
choices?: ChoiceType[]; | ||
}); |
9 changes: 9 additions & 0 deletions
9
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/boolean.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; | ||
import type { ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export type APIApplicationCommandBooleanOption = APIApplicationCommandOptionBase<ApplicationCommandOptionType.Boolean>; | ||
|
||
export type APIApplicationCommandInteractionDataBooleanOption = APIInteractionDataOptionBase< | ||
ApplicationCommandOptionType.Boolean, | ||
boolean | ||
>; |
14 changes: 14 additions & 0 deletions
14
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/channel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Snowflake } from '../../../../../globals.ts'; | ||
import type { ChannelType } from '../../../channel.ts'; | ||
import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; | ||
import type { ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export interface APIApplicationCommandChannelOption | ||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.Channel> { | ||
channel_types?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[]; | ||
} | ||
|
||
export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase< | ||
ApplicationCommandOptionType.Channel, | ||
Snowflake | ||
>; |
28 changes: 28 additions & 0 deletions
28
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/integer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { | ||
APIApplicationCommandOptionBase, | ||
APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, | ||
APIInteractionDataOptionBase, | ||
} from './base.ts'; | ||
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export interface APIApplicationCommandIntegerOptionBase | ||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.Integer> { | ||
/** | ||
* If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. | ||
*/ | ||
min_value?: number; | ||
/** | ||
* If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. | ||
*/ | ||
max_value?: number; | ||
} | ||
|
||
export type APIApplicationCommandIntegerOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< | ||
APIApplicationCommandIntegerOptionBase, | ||
APIApplicationCommandOptionChoice<number> | ||
>; | ||
|
||
export interface APIApplicationCommandInteractionDataIntegerOption | ||
extends APIInteractionDataOptionBase<ApplicationCommandOptionType.Integer, number> { | ||
focused?: boolean; | ||
} |
11 changes: 11 additions & 0 deletions
11
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/mentionable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Snowflake } from '../../../../../globals.ts'; | ||
import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; | ||
import type { ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export type APIApplicationCommandMentionableOption = | ||
APIApplicationCommandOptionBase<ApplicationCommandOptionType.Mentionable>; | ||
|
||
export type APIApplicationCommandInteractionDataMentionableOption = APIInteractionDataOptionBase< | ||
ApplicationCommandOptionType.Mentionable, | ||
Snowflake | ||
>; |
28 changes: 28 additions & 0 deletions
28
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/number.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { | ||
APIApplicationCommandOptionBase, | ||
APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, | ||
APIInteractionDataOptionBase, | ||
} from './base.ts'; | ||
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export interface APIApplicationCommandNumberOptionBase | ||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.Number> { | ||
/** | ||
* If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. | ||
*/ | ||
min_value?: number; | ||
/** | ||
* If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. | ||
*/ | ||
max_value?: number; | ||
} | ||
|
||
export type APIApplicationCommandNumberOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< | ||
APIApplicationCommandNumberOptionBase, | ||
APIApplicationCommandOptionChoice<number> | ||
>; | ||
|
||
export interface APIApplicationCommandInteractionDataNumberOption | ||
extends APIInteractionDataOptionBase<ApplicationCommandOptionType.Number, number> { | ||
focused?: boolean; | ||
} |
10 changes: 10 additions & 0 deletions
10
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/role.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Snowflake } from '../../../../../globals.ts'; | ||
import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; | ||
import type { ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export type APIApplicationCommandRoleOption = APIApplicationCommandOptionBase<ApplicationCommandOptionType.Role>; | ||
|
||
export type APIApplicationCommandInteractionDataRoleOption = APIInteractionDataOptionBase< | ||
ApplicationCommandOptionType.Role, | ||
Snowflake | ||
>; |
23 changes: 23 additions & 0 deletions
23
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/shared.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type | ||
*/ | ||
export enum ApplicationCommandOptionType { | ||
Subcommand = 1, | ||
SubcommandGroup, | ||
String, | ||
Integer, | ||
Boolean, | ||
User, | ||
Channel, | ||
Role, | ||
Mentionable, | ||
Number, | ||
} | ||
|
||
/** | ||
* https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure | ||
*/ | ||
export interface APIApplicationCommandOptionChoice<ValueType = string | number> { | ||
name: string; | ||
value: ValueType; | ||
} |
16 changes: 16 additions & 0 deletions
16
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/string.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { | ||
APIApplicationCommandOptionBase, | ||
APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, | ||
APIInteractionDataOptionBase, | ||
} from './base.ts'; | ||
import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export type APIApplicationCommandStringOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< | ||
APIApplicationCommandOptionBase<ApplicationCommandOptionType.String>, | ||
APIApplicationCommandOptionChoice<string> | ||
>; | ||
|
||
export interface APIApplicationCommandInteractionDataStringOption | ||
extends APIInteractionDataOptionBase<ApplicationCommandOptionType.String, string> { | ||
focused?: boolean; | ||
} |
14 changes: 14 additions & 0 deletions
14
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { APIApplicationCommandBasicOption, APIApplicationCommandInteractionDataBasicOption } from '../chatInput.ts'; | ||
import type { APIApplicationCommandOptionBase } from './base.ts'; | ||
import type { ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export interface APIApplicationCommandSubcommandOption | ||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.Subcommand> { | ||
options?: APIApplicationCommandBasicOption[]; | ||
} | ||
|
||
export interface APIApplicationCommandInteractionDataSubcommandOption { | ||
name: string; | ||
type: ApplicationCommandOptionType.Subcommand; | ||
options?: APIApplicationCommandInteractionDataBasicOption[]; | ||
} |
17 changes: 17 additions & 0 deletions
17
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { APIApplicationCommandOptionBase } from './base.ts'; | ||
import type { ApplicationCommandOptionType } from './shared.ts'; | ||
import type { | ||
APIApplicationCommandInteractionDataSubcommandOption, | ||
APIApplicationCommandSubcommandOption, | ||
} from './subcommand.ts'; | ||
|
||
export interface APIApplicationCommandSubcommandGroupOption | ||
extends APIApplicationCommandOptionBase<ApplicationCommandOptionType.SubcommandGroup> { | ||
options?: APIApplicationCommandSubcommandOption[]; | ||
} | ||
|
||
export interface APIApplicationCommandInteractionDataSubcommandGroupOption { | ||
name: string; | ||
type: ApplicationCommandOptionType.SubcommandGroup; | ||
options: APIApplicationCommandInteractionDataSubcommandOption[]; | ||
} |
10 changes: 10 additions & 0 deletions
10
deno/payloads/v8/_interactions/_applicationCommands/_chatInput/user.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Snowflake } from '../../../../../globals.ts'; | ||
import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; | ||
import type { ApplicationCommandOptionType } from './shared.ts'; | ||
|
||
export type APIApplicationCommandUserOption = APIApplicationCommandOptionBase<ApplicationCommandOptionType.User>; | ||
|
||
export type APIApplicationCommandInteractionDataUserOption = APIInteractionDataOptionBase< | ||
ApplicationCommandOptionType.User, | ||
Snowflake | ||
>; |
Oops, something went wrong.