types(ApplicationCommandManager): add missing overload for fetch (#6904)

This commit is contained in:
Vlad Frangu
2021-10-28 17:19:19 +03:00
committed by GitHub
parent 91a432e49d
commit ee93a27e15
2 changed files with 9 additions and 2 deletions

5
typings/index.d.ts vendored
View File

@@ -279,7 +279,6 @@ export type GuildCacheMessage<Cached extends CacheType> = CacheTypeReducer<
export abstract class BaseCommandInteraction<Cached extends CacheType = CacheType> extends Interaction<Cached> {
public options: CommandInteractionOptionResolver<Cached>;
public readonly command: ApplicationCommand | ApplicationCommand<{ guild: GuildResolvable }> | null;
public readonly channel: TextBasedChannels | null;
public channelId: Snowflake;
public commandId: Snowflake;
public commandName: string;
@@ -1077,7 +1076,7 @@ export class Interaction<Cached extends CacheType = CacheType> extends Base {
private readonly _cacheType: Cached;
protected constructor(client: Client, data: RawInteractionData);
public applicationId: Snowflake;
public channel: CacheTypeReducer<Cached, TextBasedChannels | null>;
public readonly channel: CacheTypeReducer<Cached, TextBasedChannels | null>;
public channelId: Snowflake | null;
public readonly createdAt: Date;
public readonly createdTimestamp: number;
@@ -2547,6 +2546,7 @@ export class ApplicationCommandManager<
id: Snowflake,
options: FetchApplicationCommandOptions & { guildId: Snowflake },
): Promise<ApplicationCommand>;
public fetch(options: FetchApplicationCommandOptions): Promise<Collection<string, ApplicationCommandScope>>;
public fetch(id: Snowflake, options?: FetchApplicationCommandOptions): Promise<ApplicationCommandScope>;
public fetch(
id?: Snowflake,
@@ -2629,6 +2629,7 @@ export class GuildApplicationCommandManager extends ApplicationCommandManager<Ap
data: ApplicationCommandDataResolvable,
): 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 set(commands: ApplicationCommandDataResolvable[]): Promise<Collection<Snowflake, ApplicationCommand>>;
}

View File

@@ -105,6 +105,12 @@ const guildCommandId = '234567890123456789'; // example id
client.on('ready', async () => {
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
const globalCommand = await client.application?.commands.fetch(globalCommandId);
const guildCommandFromGlobal = await client.application?.commands.fetch(guildCommandId, { guildId: testGuildId });