From 200f503110b0d45c6c45d848dadfa2359afc4a46 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Thu, 14 Jul 2022 06:44:31 -0500 Subject: [PATCH] fix(structures): type guards --- .../structures/interactions/BaseInteraction.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/biscuit/structures/interactions/BaseInteraction.ts b/packages/biscuit/structures/interactions/BaseInteraction.ts index 880ba6a..de9b0af 100644 --- a/packages/biscuit/structures/interactions/BaseInteraction.ts +++ b/packages/biscuit/structures/interactions/BaseInteraction.ts @@ -3,6 +3,9 @@ import type { Session } from "../../Session.ts"; import type { DiscordInteraction } from "../../../discordeno/mod.ts"; import type CommandInteraction from "./CommandInteraction.ts"; import type PingInteraction from "./PingInteraction.ts"; +import type ComponentInteraction from "./ComponentInteraction.ts"; +import type ModalSubmitInteraction from "./ModalSubmitInteraction.ts"; +import type AutoCompleteInteraction from "./AutoCompleteInteraction.ts"; import { InteractionTypes } from "../../../discordeno/mod.ts"; import { Snowflake } from "../../Snowflake.ts"; import User from "../User.ts"; @@ -60,11 +63,11 @@ export abstract class BaseInteraction implements Model { return this.type === InteractionTypes.ApplicationCommand; } - isAutoComplete() { + isAutoComplete(): this is AutoCompleteInteraction { return this.type === InteractionTypes.ApplicationCommandAutocomplete; } - isComponent() { + isComponent(): this is ComponentInteraction { return this.type === InteractionTypes.MessageComponent; } @@ -72,11 +75,11 @@ export abstract class BaseInteraction implements Model { return this.type === InteractionTypes.Ping; } - isModalSubmit() { + isModalSubmit(): this is ModalSubmitInteraction { return this.type === InteractionTypes.ModalSubmit; } - inGuild() { + inGuild(): this is this & { guildId: Snowflake } { return !!this.guildId; } }