Cannot type narrow APIApplicationCommandInteraction
See original GitHub issuePlease 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:
- 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:
- Created 2 years ago
- Comments:9 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
SOS
Also interaction type guards just got merged in to 0.28.0 in utils, so I guess this is solved 😃