#Interaction.type is not reducing type of Interaction

3 messages · Page 1 of 1 (latest)

forest maple
#

Having issues with getting the type of an interaction, how can I solve it?

export function interactionIsApplicationCommand<Cached extends CacheType = CacheType> (interaction: Interaction<Cached>): interaction is CommandInteraction<Cached> {
  return interaction.type === InteractionType.ApplicationCommand;
}

gives this error in place of interaction is CommandInteraction<Cached>:

A type predicate's type must be assignable to its parameter's type.
  Type 'CommandInteraction<Cached>' is not assignable to type 'Interaction<Cached>'.
    Type 'CommandInteraction<Cached>' is missing the following properties from type 'UserContextMenuCommandInteraction<Cached>': targetUser, targetMember, targetId, resolveContextMenuOptionsts(2677)
tiny waveBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

tiny linden
#

BaseInteraction not Interaction