Skip to content

Commit

Permalink
feat: restore missing typeguards
Browse files Browse the repository at this point in the history
  • Loading branch information
monbrey committed Jul 21, 2022
1 parent dda2895 commit dfabee2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/discord.js/src/structures/BaseInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ 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 ChatInputCommandInteraction}.
* @returns {boolean}
Expand All @@ -212,6 +220,14 @@ class BaseInteraction extends Base {
);
}

/**
* 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}
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,11 @@ 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 isContextMenuCommand(): this is ContextMenuCommandInteraction<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>;
Expand Down

0 comments on commit dfabee2

Please sign in to comment.