In the body of the if the variable string is not available anymore because it's only valid in the callback of some. So just loop over the blocked words and do the replacement.
blocked.forEach(string => {
if (message.includes(string)) message = message.replace(string, "blocked");
})
In principle the check isn't necessary. If the search value is not contained in the string, nothing will be replaced, so you can just do the following:
blocked.forEach(string => {
message = message.replace(string, "blocked");
})
But be aware that String::replace(search, replacement) only replaces the first occurence of search if it is a string. So if your "badword" occurs more than once, only the first occurence will be replaced. So it might be better to define your blocked words as regex, because this way you can replace multiple occurrences.
var replacements = [
/badwordone/gi,
/badwordtwo/gi
]
replacements.forEach(r => {
message = message.replace(r, "blocked");
})
blockedarray and call replace for each, replace will not work if the sentence doesn't exist, no need to pre-check