Handling Unmatched Autocomplete Inputs in Slash Commands

I’m working on a Slash Command that allows users to retrieve crafting instructions for Minecraft items with an autocomplete feature. The bot works like this: a user types /howto followed by the item name, such as "boat", and the bot displays how to craft it I'm facing an issue where if the user types too quickly, and the autocomplete doesn’t have time to match the input (e.g., /howto boat entered rapidly), the command execution fails because it receives an "undefined" value instead of "boat" Is there a way to modify the bot so it can default to using the raw input string from the user when the autocomplete fails to provide a match? I want to ensure the command remains valid and executes with the user’s input regardless of the autocomplete's speed
8 Replies
d.js toolkit
d.js toolkit8mo 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
d.js docs
d.js docs8mo ago
:method: CommandInteractionOptionResolver#getFocused() Gets the focused option.
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Ninhache
NinhacheOP8mo ago
I'm on it but not sure about this, a min please
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Ninhache
NinhacheOP8mo ago
Wait, didnt need it finally A simple : const itemToCraft = interaction.options.getString("item"); is enough to get the raw value, maybe i've done something wrong earlier
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Ninhache
NinhacheOP8mo ago
That's also on me, I've probably made a mistake earlier Thanks anyways,
Want results from more Discord servers?
Add your server