I've been working on this for the better part of 3 hours, and I'm about to just throw this part away, but I still want to know how to fix it.
DISCLAIMER- I'm new to node, and I'm still teaching myself js. This bot is my first major working project.
Basically I want this bot to respond with a random answer from an array based on what was said.
So the top 4 arrays are things the user would say + the bot's name. (Markos)
The next 5 arrays are potential responses that the bot should choose randomly. There are ~20 responses per array, so I won't include the responses.
The MENTION
array should be used if none of the words in the first four arrays are used with "Markos".
Right now, ONLY the MENTION
array is being accessed, and I'm not sure why. Insight would be great. If you could just point me in the right direction/explain why what I'm doing is wrong, I'd be very thankful.
let posGreet = ["hi", "hello", "hey", "yo", "greetings", "hallo", "Grüße"]
let posBye = ["bye", "goodbye", "later", "peace", "cya", "see you later", "tschüss", "auf wiedersehen", "bis später"]
let posThanks = ["thanks", "thank you", "vielen dank", "danke", "gracias"]
let posInsults = ["insults"]
let GREETINGS = ["too many to list"]
let THANKS = ["too many to list"]
let BYE = ["too many to list"]
let MENTION = ["too many to list"]
let INSULTS = ["too many to list"]
else if (message.content.toLowerCase().includes("markos")) {
if (message.content.toLowerCase().includes(posGreet)) {
message.reply(GREETINGS[Math.floor(Math.random() * GREETINGS.length)]);
} else if (message.content.toLowerCase().includes(posThanks)) {
message.reply(THANKS[Math.floor(Math.random() * THANKS.length)]);
} else if (message.content.toLowerCase().includes(posBye)) {
message.reply(BYE[Math.floor(Math.random() * BYE.length)]);
} else if (message.content.toLowerCase().includes(posInsults)) {
message.reply(INSULTS[Math.floor(Math.random() * INSULTS.length)]);
} else {
message.reply(MENTION[Math.floor(Math.random() * MENTION.length)]);
}
}