Ask coding questions

← Back to all posts
I've got a stranage error and don't know what to do.
Aaris16 (0)

So, I was building a Discord bot in JavaScript. The bot was pretty long and had more than 1000 lignes of code. When running it after some time to see if everything's good, I got a strange error and my new commands that I added wouldn't work.
Here is the error:

(node:1452) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit

Would appreciate any help, thanks! ;)

Answered by Coder100 (19279) [earned 5 cycles]
View Answer
Coder100 (19279)

You added a client.on function for every single command. That isn't allowed -- you should only have one.

Put all your code inside one client.on like this:

Aaris16 (0)

@Coder100 I did it. It works!The only one that still won't respond is 'atatA' near the end.

Coder100 (19279)

@naneandreimihne you made command lowercase so the equality will never be true.