Typescript issues

I just recently switched to using typescript and I am having a little trouble when trying to get options from CommandInteractions. interaction.options is a CommandInteractionOptionResolver but when i try to use it it gives me a type error saying that the type is actually anOmit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused" | "getMentionable" | "getRole" | "getAttachment" | ... 6 more ... | "getSubcommand"> which would be fine except the things it is emiting are the options I am trying to get. Eg options.getBoolean() is emitted but it is added as one of the command options. Am I missing something here or do I just have to do work arounds like explicitly telling the compiler that interaction.options as CommandInteractionOptionResolver so I can actually use my options?
5 Replies
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
kin.ts
kin.ts12mo ago
what is interaction typed as? CommandInteraction?
Mirai-Miki
Mirai-MikiOP12mo ago
Yeah
kin.ts
kin.ts12mo ago
typeguard it with interaction.isChatInputCommand()
Mirai-Miki
Mirai-MikiOP12mo ago
Thanks i will give it a try when i get home That did work, or at least I still had to do an Omit type but at least it wasn't Omitting anything I needed this time. Thanks for the help.
Want results from more Discord servers?
Add your server