Ulas GokDenîz Ulas GokDenîz - 9 months ago 28
Node.js Question

Using includes() to get a search value from a var

The below code is my attempt to gain the searchvalue from the variable "BannedWords", it doesn't work. This code uses the discord.js library. Here is it's documentation.

var BannedWords = [

if(msg.content.includes(BannedWords[msg.content.toUpperCase()])) {


You can achieve this with a regular expression:

if (new RegExp(BannedWords.join("|"), "i").test(msg.content)) {

Or using some:

if (BannedWords.some((v) => msg.content.toUpperCase().indexOf(v) >= 0)) {

Note: this is adapted to your (case insensitive) scenario from this very good answer. Refer to it for a better understanding.