boehs / useless-toast-bot

A useless toast discord bot! you ping it and it dms toast. that's all.
1 stars 2 forks source link

(pd) (node) warning: possible EventEmitter memory leak detected. #4

Open Alex-Toucan opened 2 years ago

Alex-Toucan commented 2 years ago

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.

Detected in index.js, no trace.

boehs commented 2 years ago

I'm pretty sure this is because you added 50 message event listeners. I would recommend doing something like

const list = [apple, orange]
on message ->
  if (!list.includes(message.param[0]) return
  else
    message.reply("unsplash.com/${message.param[0]}"

obviously this is pesudo code. Also saves you a few hundred loc and makes the program easier to maintain. In your case you might instead want an object

{
  "apple": "🍎"
}

to also lookup the relevent emoji. You can then call Object.entries and implement otherwise the same pesudo code above