[TypeScript] Non required option for slash commands

Hello ! I wanted to know, I rewrite my bot with TypeScript and I have a problem. When I want to get the value of non-required option, my bot crash. The concerned line (37) : let version = interaction.options.get('version', false).value as string; Thanks in advance ^^ Mysterious_Dev
9 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Mysterious_Dev
Mysterious_DevOP2y ago
I don't have getString with typescript (4.9.5) :/
Mysterious_Dev
Mysterious_DevOP2y ago
What ?? slash command interaction
Mysterious_Dev
Mysterious_DevOP2y ago
Yes it is
Mysterious_Dev
Mysterious_DevOP2y ago
So, else than set "strict" in tsconfig, do I need to do someting else to have the possibility to use getString ?
CanineData
CanineData2y ago
You need to set the parameter type of the function
Mysterious_Dev
Mysterious_DevOP2y ago
of execute function ?
Mysterious_Dev
Mysterious_DevOP2y ago
Mysterious_Dev
Mysterious_DevOP2y ago
Thanks ! I forgot I created that an interface for slash command (parameter typed with CommandInteraction insteadof ChatInputCommandInteraction). Sorry for the inconvenience ^^'.
Want results from more Discord servers?
Add your server