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 speed8 Replies
- 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 OPUnknown User•8mo ago
Message Not Public
Sign In & Join Server To View
I'm on it but not sure about this, a min please
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
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 earlierUnknown User•8mo ago
Message Not Public
Sign In & Join Server To View
That's also on me, I've probably made a mistake earlier
Thanks anyways,