message collector filter not working as intended
Hello, I'm trying to build a message collector that only collects specific numbers or phrases for a bot for a game community.
In doing so, I'm not sure why this logic isn't working. Is there another logic I can use or a change to the syntax I can use that will help me get the reply to be edited at the bottom of my code?
5 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 staffThat isn't even close to how includes works, you can't slap an || inside it
You would need an array of words, and do
words.some(word => m.content.includes(word))
This is not a discord.js issue though, just for future reference, it would belong in #other-js-tsThank you!
also contains returns the index value of the first occurance of specified value in array, if value is not found it will return -1. While includes return boolean value. As he said, your argument must be an array or a single string (array in your case).
Define phrases in array and check if the message content includes anything from phrases array
And you can use
||
but it would be:
1 sec
Another tip, you can use m.toLowerCase().includes(phrases)
and then you won’t need to add extra items to your array such as “FC”/“FC ITEMS” to handle uppercases
Doesnt it technically work with arrays even though its used for nodes and token list
Yeah I am refering to that
Didnt use it in nodejs just in web development
But I think I used a library for that, not a built-in functionthank you!