mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-05-30 07:20:10 +00:00
feat(Interactions): add autocomplete api types (#205)
This commit is contained in:
@@ -19,6 +19,7 @@ interface APIApplicationCommandOptionBase {
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
autocomplete?: never;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,8 +28,9 @@ interface APIApplicationCommandOptionBase {
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase
|
||||
| APIApplicationCommandChannelOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
| APIApplicationCommandAutocompleteOptions;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
@@ -46,12 +48,29 @@ export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicat
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
export interface APIApplicationCommandArgumentOptions
|
||||
extends Omit<APIApplicationCommandOptionBase, 'type' | 'autocomplete'> {
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Integer
|
||||
| ApplicationCommandOptionType.Number;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
autocomplete?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array,
|
||||
* but they can a `autocomplete` field where it's set to `true`
|
||||
*/
|
||||
export interface APIApplicationCommandAutocompleteOptions
|
||||
extends Omit<APIApplicationCommandOptionBase, 'type' | 'autocomplete'> {
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Integer
|
||||
| ApplicationCommandOptionType.Number;
|
||||
autocomplete: true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,10 +138,10 @@ export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionNumber
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionString
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.String, string> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
@@ -144,15 +163,15 @@ export type ApplicationCommandInteractionDataOptionMentionable = InteractionData
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionInteger
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.Integer, number> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionNumber = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Number,
|
||||
number
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionNumber
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.Number, number> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
|
||||
6
deno/payloads/v8/_interactions/autocomplete.ts
Normal file
6
deno/payloads/v8/_interactions/autocomplete.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { APIApplicationCommandInteractionData, APIBaseInteraction, InteractionType } from '../mod.ts';
|
||||
|
||||
export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction<
|
||||
InteractionType.ApplicationCommandAutocomplete,
|
||||
APIApplicationCommandInteractionData
|
||||
>;
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { MessageFlags } from '../mod.ts';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8.ts';
|
||||
import type { APIApplicationCommandOptionChoice } from './applicationCommands.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
|
||||
@@ -8,6 +9,7 @@ export enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
ApplicationCommandAutocomplete,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,12 +20,18 @@ export type APIInteractionResponse =
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
| APIInteractionResponseUpdateMessage
|
||||
| APIApplicationCommandAutocompleteResponse;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIApplicationCommandAutocompleteResponse {
|
||||
type: InteractionResponseType.ApplicationCommandAutocompleteResult;
|
||||
data: APICommandAutocompleteInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionResponseCallbackData;
|
||||
@@ -67,6 +75,10 @@ export enum InteractionResponseType {
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
/**
|
||||
* For autocomplete interactions
|
||||
*/
|
||||
ApplicationCommandAutocompleteResult,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,3 +88,7 @@ export type APIInteractionResponseCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
|
||||
export interface APICommandAutocompleteInteractionResponseCallbackData {
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
} from './_interactions/applicationCommands.ts';
|
||||
import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete.ts';
|
||||
|
||||
export * from './_interactions/base.ts';
|
||||
export * from './_interactions/messageComponents.ts';
|
||||
@@ -19,7 +20,11 @@ export * from './_interactions/applicationCommands.ts';
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
|
||||
*/
|
||||
export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction;
|
||||
export type APIInteraction =
|
||||
| APIPingInteraction
|
||||
| APIApplicationCommandInteraction
|
||||
| APIMessageComponentInteraction
|
||||
| APIApplicationCommandAutocompleteInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
|
||||
|
||||
@@ -19,6 +19,7 @@ interface APIApplicationCommandOptionBase {
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
autocomplete?: never;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,8 +28,9 @@ interface APIApplicationCommandOptionBase {
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase
|
||||
| APIApplicationCommandChannelOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
| APIApplicationCommandAutocompleteOptions;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
@@ -44,14 +46,31 @@ export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicat
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
* but they can have a either a `choices` or a `autocomplete` field where it's set to false.
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
export interface APIApplicationCommandArgumentOptions
|
||||
extends Omit<APIApplicationCommandOptionBase, 'type' | 'autocomplete'> {
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Integer
|
||||
| ApplicationCommandOptionType.Number;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
autocomplete?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array,
|
||||
* but they can a `autocomplete` field where it's set to `true`
|
||||
*/
|
||||
export interface APIApplicationCommandAutocompleteOptions
|
||||
extends Omit<APIApplicationCommandOptionBase, 'type' | 'autocomplete'> {
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Integer
|
||||
| ApplicationCommandOptionType.Number;
|
||||
autocomplete: true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,10 +138,10 @@ export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionNumber
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionString
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.String, string> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
@@ -144,15 +163,15 @@ export type ApplicationCommandInteractionDataOptionMentionable = InteractionData
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionInteger
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.Integer, number> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionNumber = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Number,
|
||||
number
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionNumber
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.Number, number> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
|
||||
6
deno/payloads/v9/_interactions/autocomplete.ts
Normal file
6
deno/payloads/v9/_interactions/autocomplete.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { APIApplicationCommandInteractionData, APIBaseInteraction, InteractionType } from '../mod.ts';
|
||||
|
||||
export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction<
|
||||
InteractionType.ApplicationCommandAutocomplete,
|
||||
APIApplicationCommandInteractionData
|
||||
>;
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { MessageFlags } from '../mod.ts';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9.ts';
|
||||
import type { APIApplicationCommandOptionChoice } from './applicationCommands.ts';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
|
||||
@@ -8,6 +9,7 @@ export enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
ApplicationCommandAutocomplete,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,12 +20,18 @@ export type APIInteractionResponse =
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
| APIInteractionResponseUpdateMessage
|
||||
| APIApplicationCommandAutocompleteResponse;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIApplicationCommandAutocompleteResponse {
|
||||
type: InteractionResponseType.ApplicationCommandAutocompleteResult;
|
||||
data: APICommandAutocompleteInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionResponseCallbackData;
|
||||
@@ -67,6 +75,10 @@ export enum InteractionResponseType {
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
/**
|
||||
* For autocomplete interactions
|
||||
*/
|
||||
ApplicationCommandAutocompleteResult,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,3 +88,7 @@ export type APIInteractionResponseCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
|
||||
export interface APICommandAutocompleteInteractionResponseCallbackData {
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
} from './_interactions/applicationCommands.ts';
|
||||
import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete.ts';
|
||||
|
||||
export * from './_interactions/base.ts';
|
||||
export * from './_interactions/messageComponents.ts';
|
||||
@@ -19,7 +20,11 @@ export * from './_interactions/applicationCommands.ts';
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
|
||||
*/
|
||||
export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction;
|
||||
export type APIInteraction =
|
||||
| APIPingInteraction
|
||||
| APIApplicationCommandInteraction
|
||||
| APIMessageComponentInteraction
|
||||
| APIApplicationCommandAutocompleteInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
|
||||
|
||||
@@ -35,6 +35,10 @@ type RESTPostAPIBaseApplicationCommandsJSONBody = Omit<
|
||||
*/
|
||||
export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
|
||||
type?: ApplicationCommandType.ChatInput;
|
||||
/**
|
||||
* Whether this application command option should be autocompleted
|
||||
*/
|
||||
autocomplete?: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ type RESTPostAPIBaseApplicationCommandsJSONBody = Omit<
|
||||
*/
|
||||
export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
|
||||
type?: ApplicationCommandType.ChatInput;
|
||||
/**
|
||||
* Whether this application command option should be autocompleted
|
||||
*/
|
||||
autocomplete?: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ interface APIApplicationCommandOptionBase {
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
autocomplete?: never;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,8 +28,9 @@ interface APIApplicationCommandOptionBase {
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase
|
||||
| APIApplicationCommandChannelOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
| APIApplicationCommandAutocompleteOptions;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
@@ -46,12 +48,29 @@ export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicat
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
export interface APIApplicationCommandArgumentOptions
|
||||
extends Omit<APIApplicationCommandOptionBase, 'type' | 'autocomplete'> {
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Integer
|
||||
| ApplicationCommandOptionType.Number;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
autocomplete?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array,
|
||||
* but they can a `autocomplete` field where it's set to `true`
|
||||
*/
|
||||
export interface APIApplicationCommandAutocompleteOptions
|
||||
extends Omit<APIApplicationCommandOptionBase, 'type' | 'autocomplete'> {
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Integer
|
||||
| ApplicationCommandOptionType.Number;
|
||||
autocomplete: true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,10 +138,10 @@ export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionNumber
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionString
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.String, string> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
@@ -144,15 +163,15 @@ export type ApplicationCommandInteractionDataOptionMentionable = InteractionData
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionInteger
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.Integer, number> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionNumber = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Number,
|
||||
number
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionNumber
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.Number, number> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
|
||||
6
payloads/v8/_interactions/autocomplete.ts
Normal file
6
payloads/v8/_interactions/autocomplete.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { APIApplicationCommandInteractionData, APIBaseInteraction, InteractionType } from '../index';
|
||||
|
||||
export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction<
|
||||
InteractionType.ApplicationCommandAutocomplete,
|
||||
APIApplicationCommandInteractionData
|
||||
>;
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { MessageFlags } from '../index';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8';
|
||||
import type { APIApplicationCommandOptionChoice } from './applicationCommands';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
|
||||
@@ -8,6 +9,7 @@ export const enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
ApplicationCommandAutocomplete,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,12 +20,18 @@ export type APIInteractionResponse =
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
| APIInteractionResponseUpdateMessage
|
||||
| APIApplicationCommandAutocompleteResponse;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIApplicationCommandAutocompleteResponse {
|
||||
type: InteractionResponseType.ApplicationCommandAutocompleteResult;
|
||||
data: APICommandAutocompleteInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionResponseCallbackData;
|
||||
@@ -67,6 +75,10 @@ export const enum InteractionResponseType {
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
/**
|
||||
* For autocomplete interactions
|
||||
*/
|
||||
ApplicationCommandAutocompleteResult,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,3 +88,7 @@ export type APIInteractionResponseCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
|
||||
export interface APICommandAutocompleteInteractionResponseCallbackData {
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
} from './_interactions/applicationCommands';
|
||||
import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete';
|
||||
|
||||
export * from './_interactions/base';
|
||||
export * from './_interactions/messageComponents';
|
||||
@@ -19,7 +20,11 @@ export * from './_interactions/applicationCommands';
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
|
||||
*/
|
||||
export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction;
|
||||
export type APIInteraction =
|
||||
| APIPingInteraction
|
||||
| APIApplicationCommandInteraction
|
||||
| APIMessageComponentInteraction
|
||||
| APIApplicationCommandAutocompleteInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
|
||||
|
||||
@@ -19,6 +19,7 @@ interface APIApplicationCommandOptionBase {
|
||||
description: string;
|
||||
default?: boolean;
|
||||
required?: boolean;
|
||||
autocomplete?: never;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,8 +28,9 @@ interface APIApplicationCommandOptionBase {
|
||||
export type APIApplicationCommandOption =
|
||||
| APIApplicationCommandArgumentOptions
|
||||
| APIApplicationCommandSubCommandOptions
|
||||
| APIApplicationCommandOptionBase
|
||||
| APIApplicationCommandChannelOptions
|
||||
| APIApplicationCommandOptionBase;
|
||||
| APIApplicationCommandAutocompleteOptions;
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
@@ -44,14 +46,31 @@ export interface APIApplicationCommandSubCommandOptions extends Omit<APIApplicat
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array,
|
||||
* but they can have a `choices` one
|
||||
* but they can have a either a `choices` or a `autocomplete` field where it's set to false.
|
||||
*/
|
||||
export interface APIApplicationCommandArgumentOptions extends Omit<APIApplicationCommandOptionBase, 'type'> {
|
||||
export interface APIApplicationCommandArgumentOptions
|
||||
extends Omit<APIApplicationCommandOptionBase, 'type' | 'autocomplete'> {
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Integer
|
||||
| ApplicationCommandOptionType.Number;
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
autocomplete?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This type is exported as a way to make it stricter for you when you're writing your commands
|
||||
*
|
||||
* In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array,
|
||||
* but they can a `autocomplete` field where it's set to `true`
|
||||
*/
|
||||
export interface APIApplicationCommandAutocompleteOptions
|
||||
extends Omit<APIApplicationCommandOptionBase, 'type' | 'autocomplete'> {
|
||||
type:
|
||||
| ApplicationCommandOptionType.String
|
||||
| ApplicationCommandOptionType.Integer
|
||||
| ApplicationCommandOptionType.Number;
|
||||
autocomplete: true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,10 +138,10 @@ export type APIApplicationCommandInteractionDataOptionWithValues =
|
||||
| ApplicationCommandInteractionDataOptionNumber
|
||||
| ApplicationCommandInteractionDataOptionBoolean;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionString = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.String,
|
||||
string
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionString
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.String, string> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Role,
|
||||
@@ -144,15 +163,15 @@ export type ApplicationCommandInteractionDataOptionMentionable = InteractionData
|
||||
Snowflake
|
||||
>;
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionInteger = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Integer,
|
||||
number
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionInteger
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.Integer, number> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionNumber = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Number,
|
||||
number
|
||||
>;
|
||||
export interface ApplicationCommandInteractionDataOptionNumber
|
||||
extends InteractionDataOptionBase<ApplicationCommandOptionType.Number, number> {
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase<
|
||||
ApplicationCommandOptionType.Boolean,
|
||||
|
||||
6
payloads/v9/_interactions/autocomplete.ts
Normal file
6
payloads/v9/_interactions/autocomplete.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { APIApplicationCommandInteractionData, APIBaseInteraction, InteractionType } from '../index';
|
||||
|
||||
export type APIApplicationCommandAutocompleteInteraction = APIBaseInteraction<
|
||||
InteractionType.ApplicationCommandAutocomplete,
|
||||
APIApplicationCommandInteractionData
|
||||
>;
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { MessageFlags } from '../index';
|
||||
import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9';
|
||||
import type { APIApplicationCommandOptionChoice } from './applicationCommands';
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type
|
||||
@@ -8,6 +9,7 @@ export const enum InteractionType {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
ApplicationCommandAutocomplete,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,12 +20,18 @@ export type APIInteractionResponse =
|
||||
| APIInteractionResponseChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredChannelMessageWithSource
|
||||
| APIInteractionResponseDeferredMessageUpdate
|
||||
| APIInteractionResponseUpdateMessage;
|
||||
| APIInteractionResponseUpdateMessage
|
||||
| APIApplicationCommandAutocompleteResponse;
|
||||
|
||||
export interface APIInteractionResponsePong {
|
||||
type: InteractionResponseType.Pong;
|
||||
}
|
||||
|
||||
export interface APIApplicationCommandAutocompleteResponse {
|
||||
type: InteractionResponseType.ApplicationCommandAutocompleteResult;
|
||||
data: APICommandAutocompleteInteractionResponseCallbackData;
|
||||
}
|
||||
|
||||
export interface APIInteractionResponseChannelMessageWithSource {
|
||||
type: InteractionResponseType.ChannelMessageWithSource;
|
||||
data: APIInteractionResponseCallbackData;
|
||||
@@ -67,6 +75,10 @@ export const enum InteractionResponseType {
|
||||
* ACK a button interaction and edit the message to which the button was attached
|
||||
*/
|
||||
UpdateMessage,
|
||||
/**
|
||||
* For autocomplete interactions
|
||||
*/
|
||||
ApplicationCommandAutocompleteResult,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,3 +88,7 @@ export type APIInteractionResponseCallbackData = Omit<
|
||||
RESTPostAPIWebhookWithTokenJSONBody,
|
||||
'username' | 'avatar_url'
|
||||
> & { flags?: MessageFlags };
|
||||
|
||||
export interface APICommandAutocompleteInteractionResponseCallbackData {
|
||||
choices?: APIApplicationCommandOptionChoice[];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
APIApplicationCommandGuildInteraction,
|
||||
APIApplicationCommandInteraction,
|
||||
} from './_interactions/applicationCommands';
|
||||
import type { APIApplicationCommandAutocompleteInteraction } from './_interactions/autocomplete';
|
||||
|
||||
export * from './_interactions/base';
|
||||
export * from './_interactions/messageComponents';
|
||||
@@ -19,7 +20,11 @@ export * from './_interactions/applicationCommands';
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
|
||||
*/
|
||||
export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction;
|
||||
export type APIInteraction =
|
||||
| APIPingInteraction
|
||||
| APIApplicationCommandInteraction
|
||||
| APIMessageComponentInteraction
|
||||
| APIApplicationCommandAutocompleteInteraction;
|
||||
|
||||
/**
|
||||
* https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object
|
||||
|
||||
@@ -35,6 +35,10 @@ type RESTPostAPIBaseApplicationCommandsJSONBody = Omit<
|
||||
*/
|
||||
export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
|
||||
type?: ApplicationCommandType.ChatInput;
|
||||
/**
|
||||
* Whether this application command option should be autocompleted
|
||||
*/
|
||||
autocomplete?: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ type RESTPostAPIBaseApplicationCommandsJSONBody = Omit<
|
||||
*/
|
||||
export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody {
|
||||
type?: ApplicationCommandType.ChatInput;
|
||||
/**
|
||||
* Whether this application command option should be autocompleted
|
||||
*/
|
||||
autocomplete?: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user