feat: restore missing typeguards (#8328)

This commit is contained in:
Ryan Munro
2022-07-25 19:12:48 +10:00
committed by GitHub
parent 4fc2c60a3b
commit 77ed407f6a
2 changed files with 36 additions and 0 deletions

View File

@@ -193,6 +193,22 @@ class BaseInteraction extends Base {
return Boolean(this.guildId && !this.guild && this.member);
}
/**
* Indicates whether this interaction is an {@link AutocompleteInteraction}
* @returns {boolean}
*/
isAutocomplete() {
return this.type === InteractionType.ApplicationCommandAutocomplete;
}
/**
* Indicates whether this interaction is a {@link CommandInteraction}
* @returns {boolean}
*/
isCommand() {
return this.type === InteractionType.ApplicationCommand;
}
/**
* Indicates whether this interaction is a {@link ChatInputCommandInteraction}.
* @returns {boolean}
@@ -212,6 +228,22 @@ class BaseInteraction extends Base {
);
}
/**
* Indicates whether this interaction is a {@link MessageComponentInteraction}
* @returns {boolean}
*/
isMessageComponent() {
return this.type === InteractionType.MessageComponent;
}
/**
* Indicates whether this interaction is a {@link ModalSubmitInteraction}
* @returns {boolean}
*/
isModalSubmit() {
return this.type === InteractionType.ModalSubmit;
}
/**
* Indicates whether this interaction is a {@link UserContextMenuCommandInteraction}
* @returns {boolean}

View File

@@ -1527,9 +1527,13 @@ export class BaseInteraction<Cached extends CacheType = CacheType> extends Base
public inCachedGuild(): this is BaseInteraction<'cached'>;
public inRawGuild(): this is BaseInteraction<'raw'>;
public isButton(): this is ButtonInteraction<Cached>;
public isAutocomplete(): this is AutocompleteInteraction<Cached>;
public isChatInputCommand(): this is ChatInputCommandInteraction<Cached>;
public isCommand(): this is CommandInteraction<Cached>;
public isContextMenuCommand(): this is ContextMenuCommandInteraction<Cached>;
public isMessageComponent(): this is MessageComponentInteraction<Cached>;
public isMessageContextMenuCommand(): this is MessageContextMenuCommandInteraction<Cached>;
public isModalSubmit(): this is ModalSubmitInteraction<Cached>;
public isUserContextMenuCommand(): this is UserContextMenuCommandInteraction<Cached>;
public isSelectMenu(): this is SelectMenuInteraction<Cached>;
public isRepliable(): this is this & InteractionResponseFields<Cached>;