Skip to content

Commit

Permalink
types: fix interaction typeguards (#6976)
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelvleeuwen authored Nov 16, 2021
1 parent 73854ee commit 06cd16f
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ export abstract class BaseCommandInteraction<Cached extends CacheType = CacheTyp
public ephemeral: boolean | null;
public replied: boolean;
public webhook: InteractionWebhook;
public inGuild(): this is BaseCommandInteraction<'present'> & this;
public inCachedGuild(): this is BaseCommandInteraction<'cached'> & this;
public inRawGuild(): this is BaseCommandInteraction<'raw'> & this;
public inGuild(): this is BaseCommandInteraction<'present'>;
public inCachedGuild(): this is BaseCommandInteraction<'cached'>;
public inRawGuild(): this is BaseCommandInteraction<'raw'>;
public deferReply(options: InteractionDeferReplyOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>;
public deferReply(options?: InteractionDeferReplyOptions): Promise<void>;
public deleteReply(): Promise<void>;
Expand Down Expand Up @@ -444,6 +444,9 @@ export class BitField<S extends string, N extends number | bigint = number> {
export class ButtonInteraction<Cached extends CacheType = CacheType> extends MessageComponentInteraction<Cached> {
private constructor(client: Client, data: RawMessageButtonInteractionData);
public componentType: 'BUTTON';
public inGuild(): this is ButtonInteraction<'present'>;
public inCachedGuild(): this is ButtonInteraction<'cached'>;
public inRawGuild(): this is ButtonInteraction<'raw'>;
}

export class CategoryChannel extends GuildChannel {
Expand Down Expand Up @@ -671,9 +674,9 @@ export interface ApplicationCommandInteractionOptionResolver<Cached extends Cach

export class CommandInteraction<Cached extends CacheType = CacheType> extends BaseCommandInteraction<Cached> {
public options: Omit<CommandInteractionOptionResolver<Cached>, 'getMessage' | 'getFocused'>;
public inGuild(): this is CommandInteraction<'present'> & this;
public inCachedGuild(): this is CommandInteraction<'cached'> & this;
public inRawGuild(): this is CommandInteraction<'raw'> & this;
public inGuild(): this is CommandInteraction<'present'>;
public inCachedGuild(): this is CommandInteraction<'cached'>;
public inRawGuild(): this is CommandInteraction<'raw'>;
public toString(): string;
}

Expand All @@ -684,9 +687,9 @@ export class AutocompleteInteraction<Cached extends CacheType = CacheType> exten
public commandName: string;
public responded: boolean;
public options: Omit<CommandInteractionOptionResolver<Cached>, 'getMessage'>;
public inGuild(): this is CommandInteraction<'present'> & this;
public inCachedGuild(): this is CommandInteraction<'cached'> & this;
public inRawGuild(): this is CommandInteraction<'raw'> & this;
public inGuild(): this is AutocompleteInteraction<'present'>;
public inCachedGuild(): this is AutocompleteInteraction<'cached'>;
public inRawGuild(): this is AutocompleteInteraction<'raw'>;
private transformOption(option: APIApplicationCommandOption): CommandInteractionOption;
public respond(options: ApplicationCommandOptionChoice[]): Promise<void>;
}
Expand Down Expand Up @@ -765,6 +768,9 @@ export class ContextMenuInteraction<Cached extends CacheType = CacheType> extend
>;
public targetId: Snowflake;
public targetType: Exclude<ApplicationCommandType, 'CHAT_INPUT'>;
public inGuild(): this is ContextMenuInteraction<'present'>;
public inCachedGuild(): this is ContextMenuInteraction<'cached'>;
public inRawGuild(): this is ContextMenuInteraction<'raw'>;
private resolveContextMenuOptions(data: APIApplicationCommandInteractionData): CommandInteractionOption<Cached>[];
}

Expand Down Expand Up @@ -1203,13 +1209,13 @@ export class Interaction<Cached extends CacheType = CacheType> extends Base {
public user: User;
public version: number;
public memberPermissions: Readonly<Permissions> | null;
public inGuild(): this is Interaction<'present'> & this;
public inCachedGuild(): this is Interaction<'cached'> & this;
public inRawGuild(): this is Interaction<'raw'> & this;
public inGuild(): this is Interaction<'present'>;
public inCachedGuild(): this is Interaction<'cached'>;
public inRawGuild(): this is Interaction<'raw'>;
public isApplicationCommand(): this is BaseCommandInteraction<Cached>;
public isButton(): this is ButtonInteraction<Cached>;
public isCommand(): this is CommandInteraction<Cached>;
public isAutocomplete(): this is AutocompleteInteraction;
public isAutocomplete(): this is AutocompleteInteraction<Cached>;
public isContextMenu(): this is ContextMenuInteraction<Cached>;
public isMessageComponent(): this is MessageComponentInteraction<Cached>;
public isSelectMenu(): this is SelectMenuInteraction<Cached>;
Expand Down Expand Up @@ -1529,9 +1535,9 @@ export class MessageComponentInteraction<Cached extends CacheType = CacheType> e
public message: CacheTypeReducer<Cached, Message, APIMessage>;
public replied: boolean;
public webhook: InteractionWebhook;
public inGuild(): this is MessageComponentInteraction<'present'> & this;
public inCachedGuild(): this is MessageComponentInteraction<'cached'> & this;
public inRawGuild(): this is MessageComponentInteraction<'raw'> & this;
public inGuild(): this is MessageComponentInteraction<'present'>;
public inCachedGuild(): this is MessageComponentInteraction<'cached'>;
public inRawGuild(): this is MessageComponentInteraction<'raw'>;
public deferReply(options: InteractionDeferReplyOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>;
public deferReply(options?: InteractionDeferReplyOptions): Promise<void>;
public deferUpdate(options: InteractionDeferUpdateOptions & { fetchReply: true }): Promise<GuildCacheMessage<Cached>>;
Expand Down Expand Up @@ -1846,6 +1852,9 @@ export class SelectMenuInteraction<Cached extends CacheType = CacheType> extends
public constructor(client: Client, data: RawMessageSelectMenuInteractionData);
public componentType: 'SELECT_MENU';
public values: string[];
public inGuild(): this is SelectMenuInteraction<'present'>;
public inCachedGuild(): this is SelectMenuInteraction<'cached'>;
public inRawGuild(): this is SelectMenuInteraction<'raw'>;
}

export class Shard extends EventEmitter {
Expand Down

0 comments on commit 06cd16f

Please sign in to comment.