From 06cd16fe970543473fdf139e9e7cf061d3ee5bf7 Mon Sep 17 00:00:00 2001 From: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> Date: Tue, 16 Nov 2021 18:32:16 +0100 Subject: [PATCH] types: fix interaction typeguards (#6976) --- typings/index.d.ts | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index a6b93b00e5dd..e0807a606d20 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -334,9 +334,9 @@ export abstract class BaseCommandInteraction & 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>; public deferReply(options?: InteractionDeferReplyOptions): Promise; public deleteReply(): Promise; @@ -444,6 +444,9 @@ export class BitField { export class ButtonInteraction extends MessageComponentInteraction { 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 { @@ -671,9 +674,9 @@ export interface ApplicationCommandInteractionOptionResolver extends BaseCommandInteraction { public options: Omit, '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; } @@ -684,9 +687,9 @@ export class AutocompleteInteraction exten public commandName: string; public responded: boolean; public options: Omit, '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; } @@ -765,6 +768,9 @@ export class ContextMenuInteraction extend >; public targetId: Snowflake; public targetType: Exclude; + public inGuild(): this is ContextMenuInteraction<'present'>; + public inCachedGuild(): this is ContextMenuInteraction<'cached'>; + public inRawGuild(): this is ContextMenuInteraction<'raw'>; private resolveContextMenuOptions(data: APIApplicationCommandInteractionData): CommandInteractionOption[]; } @@ -1203,13 +1209,13 @@ export class Interaction extends Base { public user: User; public version: number; public memberPermissions: Readonly | 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; public isButton(): this is ButtonInteraction; public isCommand(): this is CommandInteraction; - public isAutocomplete(): this is AutocompleteInteraction; + public isAutocomplete(): this is AutocompleteInteraction; public isContextMenu(): this is ContextMenuInteraction; public isMessageComponent(): this is MessageComponentInteraction; public isSelectMenu(): this is SelectMenuInteraction; @@ -1529,9 +1535,9 @@ export class MessageComponentInteraction e public message: CacheTypeReducer; 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>; public deferReply(options?: InteractionDeferReplyOptions): Promise; public deferUpdate(options: InteractionDeferUpdateOptions & { fetchReply: true }): Promise>; @@ -1846,6 +1852,9 @@ export class SelectMenuInteraction 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 {