mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
types(ApplicationCommandManager): Deprecate old *Data type usages and allow camel cased dapi types to be used (#6959)
This commit is contained in:
75
package-lock.json
generated
75
package-lock.json
generated
@@ -17,6 +17,7 @@
|
|||||||
"@types/ws": "^8.2.0",
|
"@types/ws": "^8.2.0",
|
||||||
"discord-api-types": "^0.24.0",
|
"discord-api-types": "^0.24.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
|
"type-fest": "^2.5.3",
|
||||||
"ws": "^8.2.3"
|
"ws": "^8.2.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -5861,20 +5862,6 @@
|
|||||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/fsevents": {
|
|
||||||
"version": "2.3.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
|
||||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
|
||||||
"dev": true,
|
|
||||||
"hasInstallScript": true,
|
|
||||||
"optional": true,
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/fstream": {
|
"node_modules/fstream": {
|
||||||
"version": "1.0.12",
|
"version": "1.0.12",
|
||||||
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
|
||||||
@@ -6454,6 +6441,18 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/globals/node_modules/type-fest": {
|
||||||
|
"version": "0.20.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
|
||||||
|
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/globby": {
|
"node_modules/globby": {
|
||||||
"version": "11.0.4",
|
"version": "11.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/globby/-/globby-11.0.4.tgz",
|
||||||
@@ -9727,17 +9726,6 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ow/node_modules/type-fest": {
|
|
||||||
"version": "2.5.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.5.2.tgz",
|
|
||||||
"integrity": "sha512-WMbytmAs5PUTqwGJRE+WoRrD2S0bYFtHX8k4Y/1l18CG5kqA3keJud9pPQ/r30FE9n8XRFCXF9BbccHIZzRYJw==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12.20"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/p-limit": {
|
"node_modules/p-limit": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
||||||
@@ -11368,6 +11356,7 @@
|
|||||||
"version": "2.2.2",
|
"version": "2.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz",
|
||||||
"integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==",
|
"integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==",
|
||||||
|
"deprecated": "This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"block-stream": "*",
|
"block-stream": "*",
|
||||||
@@ -12044,12 +12033,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/type-fest": {
|
"node_modules/type-fest": {
|
||||||
"version": "0.20.2",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
|
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.6.0.tgz",
|
||||||
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
|
"integrity": "sha512-XN1FDGGtaSDA6CFsCW5iolTQqFsnJ+ZF6JqSz0SqXoh4F8GY0xqUv5RYnTilpmL+sOH8OH4FX8tf9YyAPM2LDA==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=12.20"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
@@ -17193,13 +17181,6 @@
|
|||||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"fsevents": {
|
|
||||||
"version": "2.3.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
|
||||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
|
||||||
"dev": true,
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"fstream": {
|
"fstream": {
|
||||||
"version": "1.0.12",
|
"version": "1.0.12",
|
||||||
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
|
||||||
@@ -17647,6 +17628,14 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"type-fest": "^0.20.2"
|
"type-fest": "^0.20.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"type-fest": {
|
||||||
|
"version": "0.20.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
|
||||||
|
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globby": {
|
"globby": {
|
||||||
@@ -20147,11 +20136,6 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"is-obj": "^2.0.0"
|
"is-obj": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"type-fest": {
|
|
||||||
"version": "2.5.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.5.2.tgz",
|
|
||||||
"integrity": "sha512-WMbytmAs5PUTqwGJRE+WoRrD2S0bYFtHX8k4Y/1l18CG5kqA3keJud9pPQ/r30FE9n8XRFCXF9BbccHIZzRYJw=="
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -21930,10 +21914,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"type-fest": {
|
"type-fest": {
|
||||||
"version": "0.20.2",
|
"version": "2.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
|
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.6.0.tgz",
|
||||||
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
|
"integrity": "sha512-XN1FDGGtaSDA6CFsCW5iolTQqFsnJ+ZF6JqSz0SqXoh4F8GY0xqUv5RYnTilpmL+sOH8OH4FX8tf9YyAPM2LDA=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"typedarray": {
|
"typedarray": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.6",
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
"@types/ws": "^8.2.0",
|
"@types/ws": "^8.2.0",
|
||||||
"discord-api-types": "^0.24.0",
|
"discord-api-types": "^0.24.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
|
"type-fest": "^2.5.3",
|
||||||
"ws": "^8.2.3"
|
"ws": "^8.2.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"array-type": [true, "array"],
|
"array-type": [true, "array"],
|
||||||
"one-line": false,
|
"one-line": false,
|
||||||
"no-any-union": false,
|
"no-any-union": false,
|
||||||
"void-return": false
|
"void-return": false,
|
||||||
|
"unified-signatures": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
64
typings/index.d.ts
vendored
64
typings/index.d.ts
vendored
@@ -45,6 +45,7 @@ import {
|
|||||||
APIUser,
|
APIUser,
|
||||||
GatewayVoiceServerUpdateDispatchData,
|
GatewayVoiceServerUpdateDispatchData,
|
||||||
GatewayVoiceStateUpdateDispatchData,
|
GatewayVoiceStateUpdateDispatchData,
|
||||||
|
RESTPatchAPIApplicationCommandJSONBody,
|
||||||
RESTPostAPIApplicationCommandsJSONBody,
|
RESTPostAPIApplicationCommandsJSONBody,
|
||||||
Snowflake,
|
Snowflake,
|
||||||
} from 'discord-api-types/v9';
|
} from 'discord-api-types/v9';
|
||||||
@@ -137,6 +138,7 @@ import {
|
|||||||
RawWidgetData,
|
RawWidgetData,
|
||||||
RawWidgetMemberData,
|
RawWidgetMemberData,
|
||||||
} from './rawDataTypes';
|
} from './rawDataTypes';
|
||||||
|
import type { CamelCasedPropertiesDeep } from 'type-fest';
|
||||||
|
|
||||||
//#region Classes
|
//#region Classes
|
||||||
|
|
||||||
@@ -213,7 +215,7 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
|||||||
public readonly manager: ApplicationCommandManager;
|
public readonly manager: ApplicationCommandManager;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public name: string;
|
public name: string;
|
||||||
public options: ApplicationCommandOption[];
|
public options: Camelize<APIApplicationCommandOption>[];
|
||||||
public permissions: ApplicationCommandPermissionsManager<
|
public permissions: ApplicationCommandPermissionsManager<
|
||||||
PermissionsFetchType,
|
PermissionsFetchType,
|
||||||
PermissionsFetchType,
|
PermissionsFetchType,
|
||||||
@@ -224,23 +226,29 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
|||||||
public type: ApplicationCommandType;
|
public type: ApplicationCommandType;
|
||||||
public version: Snowflake;
|
public version: Snowflake;
|
||||||
public delete(): Promise<ApplicationCommand<PermissionsFetchType>>;
|
public delete(): Promise<ApplicationCommand<PermissionsFetchType>>;
|
||||||
|
/** @deprecated use `edit(Camelize<RESTPatchAPIApplicationCommandJSONBody>)` instead */
|
||||||
public edit(data: ApplicationCommandData): Promise<ApplicationCommand<PermissionsFetchType>>;
|
public edit(data: ApplicationCommandData): Promise<ApplicationCommand<PermissionsFetchType>>;
|
||||||
|
public edit(
|
||||||
|
data: Camelize<RESTPatchAPIApplicationCommandJSONBody>,
|
||||||
|
): Promise<ApplicationCommand<PermissionsFetchType>>;
|
||||||
public equals(
|
public equals(
|
||||||
command: ApplicationCommand | ApplicationCommandData | RawApplicationCommandData,
|
command: ApplicationCommand | Camelize<RESTPatchAPIApplicationCommandJSONBody> | RawApplicationCommandData,
|
||||||
enforceOptionorder?: boolean,
|
enforceOptionorder?: boolean,
|
||||||
): boolean;
|
): boolean;
|
||||||
public static optionsEqual(
|
public static optionsEqual(
|
||||||
existing: ApplicationCommandOption[],
|
existing: Camelize<APIApplicationCommandOption>[],
|
||||||
options: ApplicationCommandOption[] | ApplicationCommandOptionData[] | APIApplicationCommandOption[],
|
options: Camelize<APIApplicationCommandOption>[] | APIApplicationCommandOption[],
|
||||||
enforceOptionorder?: boolean,
|
enforceOptionorder?: boolean,
|
||||||
): boolean;
|
): boolean;
|
||||||
private static _optionEquals(
|
private static _optionEquals(
|
||||||
existing: ApplicationCommandOption,
|
existing: Camelize<APIApplicationCommandOption>[],
|
||||||
options: ApplicationCommandOption | ApplicationCommandOptionData | APIApplicationCommandOption,
|
options: Camelize<APIApplicationCommandOption>[] | APIApplicationCommandOption,
|
||||||
enforceOptionorder?: boolean,
|
enforceOptionorder?: boolean,
|
||||||
): boolean;
|
): boolean;
|
||||||
private static transformOption(option: ApplicationCommandOptionData, received?: boolean): unknown;
|
private static transformOption(option: Camelize<APIApplicationCommandOption>, received?: boolean): unknown;
|
||||||
private static transformCommand(command: ApplicationCommandData): RESTPostAPIApplicationCommandsJSONBody;
|
private static transformCommand(
|
||||||
|
command: Camelize<RESTPostAPIApplicationCommandsJSONBody>,
|
||||||
|
): RESTPostAPIApplicationCommandsJSONBody;
|
||||||
private static isAPICommandData(command: object): command is RESTPostAPIApplicationCommandsJSONBody;
|
private static isAPICommandData(command: object): command is RESTPostAPIApplicationCommandsJSONBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2336,10 +2344,8 @@ export class WebhookClient extends WebhookMixin(BaseClient) {
|
|||||||
options: string | MessagePayload | WebhookEditMessageOptions,
|
options: string | MessagePayload | WebhookEditMessageOptions,
|
||||||
): Promise<APIMessage>;
|
): Promise<APIMessage>;
|
||||||
public fetchMessage(message: Snowflake, options?: WebhookFetchMessageOptions): Promise<APIMessage>;
|
public fetchMessage(message: Snowflake, options?: WebhookFetchMessageOptions): Promise<APIMessage>;
|
||||||
/* tslint:disable:unified-signatures */
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
public fetchMessage(message: Snowflake, cache?: boolean): Promise<APIMessage>;
|
public fetchMessage(message: Snowflake, cache?: boolean): Promise<APIMessage>;
|
||||||
/* tslint:enable:unified-signatures */
|
|
||||||
public send(options: string | MessagePayload | WebhookMessageOptions): Promise<APIMessage>;
|
public send(options: string | MessagePayload | WebhookMessageOptions): Promise<APIMessage>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2640,7 +2646,9 @@ export abstract class CachedManager<K, Holds, R> extends DataManager<K, Holds, R
|
|||||||
private _add(data: unknown, cache?: boolean, { id, extras }?: { id: K; extras: unknown[] }): Holds;
|
private _add(data: unknown, cache?: boolean, { id, extras }?: { id: K; extras: unknown[] }): Holds;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ApplicationCommandDataResolvable = ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody;
|
export type ApplicationCommandDataResolvable =
|
||||||
|
| Camelize<RESTPostAPIApplicationCommandsJSONBody>
|
||||||
|
| RESTPostAPIApplicationCommandsJSONBody;
|
||||||
|
|
||||||
export class ApplicationCommandManager<
|
export class ApplicationCommandManager<
|
||||||
ApplicationCommandScope = ApplicationCommand<{ guild: GuildResolvable }>,
|
ApplicationCommandScope = ApplicationCommand<{ guild: GuildResolvable }>,
|
||||||
@@ -2656,7 +2664,18 @@ export class ApplicationCommandManager<
|
|||||||
null
|
null
|
||||||
>;
|
>;
|
||||||
private commandPath({ id, guildId }: { id?: Snowflake; guildId?: Snowflake }): unknown;
|
private commandPath({ id, guildId }: { id?: Snowflake; guildId?: Snowflake }): unknown;
|
||||||
|
/** @deprecated use `create(ApplicationCommandDataResolvable)` instead */
|
||||||
|
public create(
|
||||||
|
command: ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody,
|
||||||
|
): Promise<ApplicationCommandScope>;
|
||||||
|
/** @deprecated use `create(ApplicationCommandDataResolvable, Snowflake)` instead */
|
||||||
|
public create(
|
||||||
|
command: ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody,
|
||||||
|
guildId: Snowflake,
|
||||||
|
): Promise<ApplicationCommand>;
|
||||||
public create(command: ApplicationCommandDataResolvable, guildId?: Snowflake): Promise<ApplicationCommandScope>;
|
public create(command: ApplicationCommandDataResolvable, guildId?: Snowflake): Promise<ApplicationCommandScope>;
|
||||||
|
/** @deprecated use `delete(ApplicationCommandDataResolvable, Snowflake?)` instead */
|
||||||
|
public delete(command: ApplicationCommandData, guildId?: Snowflake): Promise<ApplicationCommandScope | null>;
|
||||||
public delete(command: ApplicationCommandResolvable, guildId?: Snowflake): Promise<ApplicationCommandScope | null>;
|
public delete(command: ApplicationCommandResolvable, guildId?: Snowflake): Promise<ApplicationCommandScope | null>;
|
||||||
public edit(
|
public edit(
|
||||||
command: ApplicationCommandResolvable,
|
command: ApplicationCommandResolvable,
|
||||||
@@ -2677,13 +2696,20 @@ export class ApplicationCommandManager<
|
|||||||
id?: Snowflake,
|
id?: Snowflake,
|
||||||
options?: FetchApplicationCommandOptions,
|
options?: FetchApplicationCommandOptions,
|
||||||
): Promise<Collection<Snowflake, ApplicationCommandScope>>;
|
): Promise<Collection<Snowflake, ApplicationCommandScope>>;
|
||||||
|
/** @deprecated Use `set(ApplicationCommandResolvable)` instead */
|
||||||
|
public set(commands: ApplicationCommandData[]): Promise<Collection<Snowflake, ApplicationCommandScope>>;
|
||||||
|
/** @deprecated Use `set(ApplicationCommandResolvable, Snowflake)` instead */
|
||||||
|
public set(
|
||||||
|
commands: ApplicationCommandData[],
|
||||||
|
guildId: Snowflake,
|
||||||
|
): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||||
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommandScope>>;
|
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommandScope>>;
|
||||||
public set(
|
public set(
|
||||||
commands: ApplicationCommandDataResolvable[],
|
commands: ApplicationCommandDataResolvable[],
|
||||||
guildId: Snowflake,
|
guildId: Snowflake,
|
||||||
): Promise<Collection<Snowflake, ApplicationCommand>>;
|
): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||||
private static transformCommand(
|
private static transformCommand(
|
||||||
command: ApplicationCommandData,
|
command: Camelize<RESTPostAPIApplicationCommandsJSONBody>,
|
||||||
): Omit<APIApplicationCommand, 'id' | 'application_id' | 'guild_id'>;
|
): Omit<APIApplicationCommand, 'id' | 'application_id' | 'guild_id'>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2748,7 +2774,9 @@ export class GuildApplicationCommandManager extends ApplicationCommandManager<Ap
|
|||||||
private constructor(guild: Guild, iterable?: Iterable<RawApplicationCommandData>);
|
private constructor(guild: Guild, iterable?: Iterable<RawApplicationCommandData>);
|
||||||
public guild: Guild;
|
public guild: Guild;
|
||||||
public create(command: ApplicationCommandDataResolvable): Promise<ApplicationCommand>;
|
public create(command: ApplicationCommandDataResolvable): Promise<ApplicationCommand>;
|
||||||
public delete(command: ApplicationCommandResolvable): Promise<ApplicationCommand | null>;
|
/** @deprecated use `delete(ApplicationCommandDataResolvable, Snowflake?)` instead */
|
||||||
|
public delete(command: ApplicationCommandData, guildId?: Snowflake): Promise<ApplicationCommand | null>;
|
||||||
|
public delete(command: ApplicationCommandResolvable, guildId?: Snowflake): Promise<ApplicationCommand | null>;
|
||||||
public edit(
|
public edit(
|
||||||
command: ApplicationCommandResolvable,
|
command: ApplicationCommandResolvable,
|
||||||
data: ApplicationCommandDataResolvable,
|
data: ApplicationCommandDataResolvable,
|
||||||
@@ -2756,6 +2784,8 @@ export class GuildApplicationCommandManager extends ApplicationCommandManager<Ap
|
|||||||
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<ApplicationCommand>;
|
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<ApplicationCommand>;
|
||||||
public fetch(options: BaseFetchOptions): Promise<Collection<Snowflake, ApplicationCommand>>;
|
public fetch(options: BaseFetchOptions): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||||
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, ApplicationCommand>>;
|
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||||
|
/** @deprecated Use `set(ApplicationCommandResolvable)` instead */
|
||||||
|
public set(commands: ApplicationCommandData[]): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||||
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommand>>;
|
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3074,10 +3104,8 @@ export interface PartialWebhookFields {
|
|||||||
options: string | MessagePayload | WebhookEditMessageOptions,
|
options: string | MessagePayload | WebhookEditMessageOptions,
|
||||||
): Promise<Message | APIMessage>;
|
): Promise<Message | APIMessage>;
|
||||||
fetchMessage(message: Snowflake | '@original', options?: WebhookFetchMessageOptions): Promise<Message | APIMessage>;
|
fetchMessage(message: Snowflake | '@original', options?: WebhookFetchMessageOptions): Promise<Message | APIMessage>;
|
||||||
/* tslint:disable:unified-signatures */
|
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | APIMessage>;
|
fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | APIMessage>;
|
||||||
/* tslint:enable:unified-signatures */
|
|
||||||
send(options: string | MessagePayload | WebhookMessageOptions): Promise<Message | APIMessage>;
|
send(options: string | MessagePayload | WebhookMessageOptions): Promise<Message | APIMessage>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3343,6 +3371,7 @@ export interface ChatInputApplicationCommandData extends BaseApplicationCommandD
|
|||||||
options?: ApplicationCommandOptionData[];
|
options?: ApplicationCommandOptionData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated use `Camelize<RESTPostApplicationCommandBody>` instead */
|
||||||
export type ApplicationCommandData =
|
export type ApplicationCommandData =
|
||||||
| UserApplicationCommandData
|
| UserApplicationCommandData
|
||||||
| MessageApplicationCommandData
|
| MessageApplicationCommandData
|
||||||
@@ -3430,6 +3459,10 @@ export interface ApplicationCommandNonOptions extends BaseApplicationCommandOpti
|
|||||||
type: Exclude<CommandOptionNonChoiceResolvableType, ApplicationCommandOptionTypes>;
|
type: Exclude<CommandOptionNonChoiceResolvableType, ApplicationCommandOptionTypes>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type alias since the lib name is very long.
|
||||||
|
export type Camelize<T> = CamelCasedPropertiesDeep<T>;
|
||||||
|
|
||||||
|
/** @deprecated Use `Camelize<APIApplicationCommandsOption>` instead. */
|
||||||
export type ApplicationCommandOptionData =
|
export type ApplicationCommandOptionData =
|
||||||
| ApplicationCommandSubGroupData
|
| ApplicationCommandSubGroupData
|
||||||
| ApplicationCommandNonOptionsData
|
| ApplicationCommandNonOptionsData
|
||||||
@@ -3439,6 +3472,7 @@ export type ApplicationCommandOptionData =
|
|||||||
| ApplicationCommandNumericOptionData
|
| ApplicationCommandNumericOptionData
|
||||||
| ApplicationCommandSubCommandData;
|
| ApplicationCommandSubCommandData;
|
||||||
|
|
||||||
|
/** @deprecated use `Camelize<APIApplicationCommandOption>` instead */
|
||||||
export type ApplicationCommandOption =
|
export type ApplicationCommandOption =
|
||||||
| ApplicationCommandSubGroup
|
| ApplicationCommandSubGroup
|
||||||
| ApplicationCommandNonOptions
|
| ApplicationCommandNonOptions
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { ChildProcess } from 'child_process';
|
import {
|
||||||
import type {
|
|
||||||
APIInteractionGuildMember,
|
APIInteractionGuildMember,
|
||||||
APIMessage,
|
APIMessage,
|
||||||
APIPartialChannel,
|
APIPartialChannel,
|
||||||
@@ -7,15 +6,21 @@ import type {
|
|||||||
APIInteractionDataResolvedGuildMember,
|
APIInteractionDataResolvedGuildMember,
|
||||||
APIInteractionDataResolvedChannel,
|
APIInteractionDataResolvedChannel,
|
||||||
APIRole,
|
APIRole,
|
||||||
|
ChannelType,
|
||||||
|
ApplicationCommandOptionType,
|
||||||
|
APIApplicationCommand,
|
||||||
|
APIApplicationCommandOption,
|
||||||
|
APIApplicationCommandSubCommandOptions,
|
||||||
} from 'discord-api-types/v9';
|
} from 'discord-api-types/v9';
|
||||||
|
import type { ChildProcess } from 'node:child_process';
|
||||||
import {
|
import {
|
||||||
ApplicationCommand,
|
ApplicationCommand,
|
||||||
ApplicationCommandData,
|
ApplicationCommandChannelOptionData,
|
||||||
|
ApplicationCommandChoicesData,
|
||||||
ApplicationCommandManager,
|
ApplicationCommandManager,
|
||||||
ApplicationCommandOptionData,
|
ApplicationCommandNonOptionsData,
|
||||||
ApplicationCommandResolvable,
|
ApplicationCommandResolvable,
|
||||||
ApplicationCommandSubCommandData,
|
ApplicationCommandSubCommandData,
|
||||||
ApplicationCommandSubGroupData,
|
|
||||||
BaseCommandInteraction,
|
BaseCommandInteraction,
|
||||||
ButtonInteraction,
|
ButtonInteraction,
|
||||||
CacheType,
|
CacheType,
|
||||||
@@ -28,7 +33,6 @@ import {
|
|||||||
CommandInteraction,
|
CommandInteraction,
|
||||||
CommandInteractionOption,
|
CommandInteractionOption,
|
||||||
CommandInteractionOptionResolver,
|
CommandInteractionOptionResolver,
|
||||||
CommandOptionNonChoiceResolvableType,
|
|
||||||
Constants,
|
Constants,
|
||||||
ContextMenuInteraction,
|
ContextMenuInteraction,
|
||||||
DMChannel,
|
DMChannel,
|
||||||
@@ -77,6 +81,9 @@ import {
|
|||||||
User,
|
User,
|
||||||
VoiceChannel,
|
VoiceChannel,
|
||||||
Shard,
|
Shard,
|
||||||
|
Camelize,
|
||||||
|
ApplicationCommandAutocompleteOption,
|
||||||
|
ApplicationCommandNumericOptionData,
|
||||||
WebSocketShard,
|
WebSocketShard,
|
||||||
Collector,
|
Collector,
|
||||||
} from '.';
|
} from '.';
|
||||||
@@ -686,6 +693,20 @@ client.login('absolutely-valid-token');
|
|||||||
// Test client conditional types
|
// Test client conditional types
|
||||||
client.on('ready', client => {
|
client.on('ready', client => {
|
||||||
expectType<Client<true>>(client);
|
expectType<Client<true>>(client);
|
||||||
|
|
||||||
|
// Test camelized post command data.
|
||||||
|
client.application.commands.create({
|
||||||
|
name: 'Foo',
|
||||||
|
description: 'Bar',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'test',
|
||||||
|
description: 'test',
|
||||||
|
type: ApplicationCommandOptionType.Channel,
|
||||||
|
channelTypes: [ChannelType.GuildCategory],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
declare const loggedInClient: Client<true>;
|
declare const loggedInClient: Client<true>;
|
||||||
@@ -783,7 +804,7 @@ expectType<1>(Constants.Status.CONNECTING);
|
|||||||
expectType<0>(Constants.Opcodes.DISPATCH);
|
expectType<0>(Constants.Opcodes.DISPATCH);
|
||||||
expectType<2>(Constants.ClientApplicationAssetTypes.BIG);
|
expectType<2>(Constants.ClientApplicationAssetTypes.BIG);
|
||||||
|
|
||||||
declare const applicationCommandData: ApplicationCommandData;
|
declare const applicationCommandData: Camelize<APIApplicationCommand>;
|
||||||
declare const applicationCommandResolvable: ApplicationCommandResolvable;
|
declare const applicationCommandResolvable: ApplicationCommandResolvable;
|
||||||
declare const applicationCommandManager: ApplicationCommandManager;
|
declare const applicationCommandManager: ApplicationCommandManager;
|
||||||
{
|
{
|
||||||
@@ -805,22 +826,29 @@ declare const applicationCommandManager: ApplicationCommandManager;
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const applicationNonChoiceOptionData: ApplicationCommandOptionData & {
|
declare const applicationSubGroupCommandData: Camelize<APIApplicationCommandSubCommandOptions>;
|
||||||
type: CommandOptionNonChoiceResolvableType;
|
|
||||||
};
|
|
||||||
{
|
{
|
||||||
// Options aren't allowed on this command type.
|
expectType<ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup>(
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
applicationNonChoiceOptionData.choices;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare const applicationSubGroupCommandData: ApplicationCommandSubGroupData;
|
|
||||||
{
|
|
||||||
expectType<'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP>(
|
|
||||||
applicationSubGroupCommandData.type,
|
applicationSubGroupCommandData.type,
|
||||||
);
|
);
|
||||||
expectType<ApplicationCommandSubCommandData[] | undefined>(applicationSubGroupCommandData.options);
|
expectAssignable<APIApplicationCommandOption[] | undefined>(applicationSubGroupCommandData.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
declare const applicationSubCommandData: ApplicationCommandSubCommandData;
|
||||||
|
{
|
||||||
|
expectType<'SUB_COMMAND' | ApplicationCommandOptionTypes.SUB_COMMAND>(applicationSubCommandData.type);
|
||||||
|
|
||||||
|
// Check that only subcommands can have no subcommand or subcommand group sub-options.
|
||||||
|
expectType<
|
||||||
|
| (
|
||||||
|
| ApplicationCommandChoicesData
|
||||||
|
| ApplicationCommandNonOptionsData
|
||||||
|
| ApplicationCommandChannelOptionData
|
||||||
|
| ApplicationCommandAutocompleteOption
|
||||||
|
| ApplicationCommandNumericOptionData
|
||||||
|
)[]
|
||||||
|
| undefined
|
||||||
|
>(applicationSubCommandData.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const guildApplicationCommandManager: GuildApplicationCommandManager;
|
declare const guildApplicationCommandManager: GuildApplicationCommandManager;
|
||||||
|
|||||||
Reference in New Issue
Block a user