mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
feat: Add support for API command types in ApplicationCommandManager (#6621)
This commit is contained in:
29
typings/index.d.ts
vendored
29
typings/index.d.ts
vendored
@@ -45,6 +45,7 @@ import {
|
||||
APIUser,
|
||||
GatewayVoiceServerUpdateDispatchData,
|
||||
GatewayVoiceStateUpdateDispatchData,
|
||||
RESTPostAPIApplicationCommandsJSONBody,
|
||||
Snowflake,
|
||||
} from 'discord-api-types/v9';
|
||||
import { EventEmitter } from 'events';
|
||||
@@ -237,6 +238,8 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
||||
enforceOptionorder?: boolean,
|
||||
): boolean;
|
||||
private static transformOption(option: ApplicationCommandOptionData, received?: boolean): unknown;
|
||||
private static transformCommand(command: ApplicationCommandData): RESTPostAPIApplicationCommandsJSONBody;
|
||||
private static isAPICommandData(command: object): command is RESTPostAPIApplicationCommandsJSONBody;
|
||||
}
|
||||
|
||||
export type ApplicationResolvable = Application | Activity | Snowflake;
|
||||
@@ -2400,6 +2403,8 @@ 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;
|
||||
}
|
||||
|
||||
export type ApplicationCommandDataResolvable = ApplicationCommandData | RESTPostAPIApplicationCommandsJSONBody;
|
||||
|
||||
export class ApplicationCommandManager<
|
||||
ApplicationCommandScope = ApplicationCommand<{ guild: GuildResolvable }>,
|
||||
PermissionsOptionsExtras = { guild: GuildResolvable },
|
||||
@@ -2414,13 +2419,16 @@ export class ApplicationCommandManager<
|
||||
null
|
||||
>;
|
||||
private commandPath({ id, guildId }: { id?: Snowflake; guildId?: Snowflake }): unknown;
|
||||
public create(command: ApplicationCommandData): Promise<ApplicationCommandScope>;
|
||||
public create(command: ApplicationCommandData, guildId: Snowflake): Promise<ApplicationCommand>;
|
||||
public create(command: ApplicationCommandDataResolvable): Promise<ApplicationCommandScope>;
|
||||
public create(command: ApplicationCommandDataResolvable, guildId: Snowflake): Promise<ApplicationCommand>;
|
||||
public delete(command: ApplicationCommandResolvable, guildId?: Snowflake): Promise<ApplicationCommandScope | null>;
|
||||
public edit(command: ApplicationCommandResolvable, data: ApplicationCommandData): Promise<ApplicationCommandScope>;
|
||||
public edit(
|
||||
command: ApplicationCommandResolvable,
|
||||
data: ApplicationCommandData,
|
||||
data: ApplicationCommandDataResolvable,
|
||||
): Promise<ApplicationCommandScope>;
|
||||
public edit(
|
||||
command: ApplicationCommandResolvable,
|
||||
data: ApplicationCommandDataResolvable,
|
||||
guildId: Snowflake,
|
||||
): Promise<ApplicationCommand>;
|
||||
public fetch(
|
||||
@@ -2432,9 +2440,9 @@ export class ApplicationCommandManager<
|
||||
id?: Snowflake,
|
||||
options?: FetchApplicationCommandOptions,
|
||||
): Promise<Collection<Snowflake, ApplicationCommandScope>>;
|
||||
public set(commands: ApplicationCommandData[]): Promise<Collection<Snowflake, ApplicationCommandScope>>;
|
||||
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommandScope>>;
|
||||
public set(
|
||||
commands: ApplicationCommandData[],
|
||||
commands: ApplicationCommandDataResolvable[],
|
||||
guildId: Snowflake,
|
||||
): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||
private static transformCommand(
|
||||
@@ -2502,12 +2510,15 @@ export class ChannelManager extends CachedManager<Snowflake, Channel, ChannelRes
|
||||
export class GuildApplicationCommandManager extends ApplicationCommandManager<ApplicationCommand, {}, Guild> {
|
||||
public constructor(guild: Guild, iterable?: Iterable<RawApplicationCommandData>);
|
||||
public guild: Guild;
|
||||
public create(command: ApplicationCommandData): Promise<ApplicationCommand>;
|
||||
public create(command: ApplicationCommandDataResolvable): Promise<ApplicationCommand>;
|
||||
public delete(command: ApplicationCommandResolvable): Promise<ApplicationCommand | null>;
|
||||
public edit(command: ApplicationCommandResolvable, data: ApplicationCommandData): Promise<ApplicationCommand>;
|
||||
public edit(
|
||||
command: ApplicationCommandResolvable,
|
||||
data: ApplicationCommandDataResolvable,
|
||||
): Promise<ApplicationCommand>;
|
||||
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<ApplicationCommand>;
|
||||
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||
public set(commands: ApplicationCommandData[]): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||
}
|
||||
|
||||
export class GuildChannelManager extends CachedManager<
|
||||
|
||||
Reference in New Issue
Block a user