mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13: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> {
|
||||
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>>;
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user