mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
types(ApplicationCommandManager): add missing overload for fetch (#6904)
This commit is contained in:
5
typings/index.d.ts
vendored
5
typings/index.d.ts
vendored
@@ -279,7 +279,6 @@ export type GuildCacheMessage<Cached extends CacheType> = CacheTypeReducer<
|
|||||||
export abstract class BaseCommandInteraction<Cached extends CacheType = CacheType> extends Interaction<Cached> {
|
export abstract class BaseCommandInteraction<Cached extends CacheType = CacheType> extends Interaction<Cached> {
|
||||||
public options: CommandInteractionOptionResolver<Cached>;
|
public options: CommandInteractionOptionResolver<Cached>;
|
||||||
public readonly command: ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null;
|
public readonly command: ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null;
|
||||||
public readonly channel: TextBasedChannels | null;
|
|
||||||
public channelId: Snowflake;
|
public channelId: Snowflake;
|
||||||
public commandId: Snowflake;
|
public commandId: Snowflake;
|
||||||
public commandName: string;
|
public commandName: string;
|
||||||
@@ -1077,7 +1076,7 @@ export class Interaction<Cached extends CacheType = CacheType> extends Base {
|
|||||||
private readonly _cacheType: Cached;
|
private readonly _cacheType: Cached;
|
||||||
protected constructor(client: Client, data: RawInteractionData);
|
protected constructor(client: Client, data: RawInteractionData);
|
||||||
public applicationId: Snowflake;
|
public applicationId: Snowflake;
|
||||||
public channel: CacheTypeReducer<Cached, TextBasedChannels | null>;
|
public readonly channel: CacheTypeReducer<Cached, TextBasedChannels | null>;
|
||||||
public channelId: Snowflake | null;
|
public channelId: Snowflake | null;
|
||||||
public readonly createdAt: Date;
|
public readonly createdAt: Date;
|
||||||
public readonly createdTimestamp: number;
|
public readonly createdTimestamp: number;
|
||||||
@@ -2547,6 +2546,7 @@ export class ApplicationCommandManager<
|
|||||||
id: Snowflake,
|
id: Snowflake,
|
||||||
options: FetchApplicationCommandOptions & { guildId: Snowflake },
|
options: FetchApplicationCommandOptions & { guildId: Snowflake },
|
||||||
): Promise<ApplicationCommand>;
|
): Promise<ApplicationCommand>;
|
||||||
|
public fetch(options: FetchApplicationCommandOptions): Promise<Collection<string, ApplicationCommandScope>>;
|
||||||
public fetch(id: Snowflake, options?: FetchApplicationCommandOptions): Promise<ApplicationCommandScope>;
|
public fetch(id: Snowflake, options?: FetchApplicationCommandOptions): Promise<ApplicationCommandScope>;
|
||||||
public fetch(
|
public fetch(
|
||||||
id?: Snowflake,
|
id?: Snowflake,
|
||||||
@@ -2629,6 +2629,7 @@ export class GuildApplicationCommandManager extends ApplicationCommandManager<Ap
|
|||||||
data: ApplicationCommandDataResolvable,
|
data: ApplicationCommandDataResolvable,
|
||||||
): Promise<ApplicationCommand>;
|
): Promise<ApplicationCommand>;
|
||||||
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(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, ApplicationCommand>>;
|
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||||
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommand>>;
|
public set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommand>>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,12 @@ const guildCommandId = '234567890123456789'; // example id
|
|||||||
client.on('ready', async () => {
|
client.on('ready', async () => {
|
||||||
console.log(`Client is logged in as ${client.user!.tag} and ready!`);
|
console.log(`Client is logged in as ${client.user!.tag} and ready!`);
|
||||||
|
|
||||||
|
// Test fetching all global commands and ones from one guild
|
||||||
|
assertType<Collection<string, ApplicationCommand>>(await client.application!.commands.fetch());
|
||||||
|
assertType<Collection<string, ApplicationCommand>>(
|
||||||
|
await client.application!.commands.fetch({ guildId: testGuildId }),
|
||||||
|
);
|
||||||
|
|
||||||
// Test command manager methods
|
// Test command manager methods
|
||||||
const globalCommand = await client.application?.commands.fetch(globalCommandId);
|
const globalCommand = await client.application?.commands.fetch(globalCommandId);
|
||||||
const guildCommandFromGlobal = await client.application?.commands.fetch(guildCommandId, { guildId: testGuildId });
|
const guildCommandFromGlobal = await client.application?.commands.fetch(guildCommandId, { guildId: testGuildId });
|
||||||
|
|||||||
Reference in New Issue
Block a user