question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot type narrow APIApplicationCommandInteraction

See original GitHub issue

Please describe the problem you are having in as much detail as possible:

When trying to type narrow interaction object, it is impossible to type narrow it to chat input. I looked at interaction types and I can’t work out why it is like that, so I’m asking for help. Maybe it is my issue, but I do not think so.

Include a reproducible code sample here, if possible:

I have function that takes interaction as APIChatInputApplicationCommandInteraction.

// Say you have an interaction and want to check if it's chat input (slash command)
if (interaction.type === 2 && interaction.data.type === 1) {
  // here interaction should definitely be chat input
  // but it's not, it still APIApplicationCommandInteraction
  // and can't assign to APIChatInputApplicationCommandInteraction
  await this.execute(interaction); // Type "APIApplicationCommandInteraction" not assignable to "APIChatInputApplicationCommandInteraction"

Further details:

CleanShot 2022-02-18 at 20 43 04@2x
  • Runtime:
    • Node.js version: v17.5.0
  • Priority this issue should have – please be realistic and elaborate if possible: Medium because it is a bug but can be bypass, e.g. by interaction as APIChatInputApplicationCommandInteraction

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
LoreSorticommented, Feb 20, 2022

SOS

0reactions
andre4ik3commented, Mar 8, 2022

Also interaction type guards just got merged in to 0.28.0 in utils, so I guess this is solved 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interactions API Reference - Discord.py - Read the Docs
Application commands (AKA Slash commands) cannot use InteractionResponseType.deferred_message_update . Raises. HTTPException – Deferring the interaction failed.
Read more >
Slash Commands and Interactions · Issue #1470 - GitHub
I've compiled a small list of major issues that have not been addressed before releasing slash commands. Some of these things would now...
Read more >
Discord.js API "Missing Access" while registering my slash ...
Unfortunately, if your app does not have the applications.commands intent in a guild, it cannot create slash commands there.
Read more >
Autocomplete - discord.js Guide
Autocomplete. Autocomplete allows you to dynamically provide a selection of values to the user, based on their input, rather than relying on ...
Read more >
Interactions - Discord4J Docs!
Application commands encompass several types of interactions: A chat input command (formerly "slash command"), which allows users to type a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found