Color Check for String
I was wanting to see how I would go about validating a string as a color.
I am using a command to change the color of the member's role and if you input anything that isn't valid it kills the bot.
I am mainly wanting something like
new Color(colorString);
and checking if that isn't null before passing it to the role.setColor()
function7 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 OPDiscord.JS:
14.14.1
NodeJS: 20.11.0
This is what is used inside @discordjs/builders using @sapphire/shapeshift
GitHub
discord.js/packages/builders/src/messages/embed/Assertions.ts at ma...
A powerful JavaScript library for interacting with the Discord API - discordjs/discord.js
That will help for the hex, I supposed I would also have to make an array of valid strings to check if it is one of those as well.
Going to give it a try lol
I had this:
But it was printing the error and still crashed the bot
I have it working now so its alright lol