Skip to main content
2 of 2
Improve formatting
janos
  • 113.1k
  • 15
  • 154
  • 396

You can simplify all of the basic text responses by putting them into a table. Instead of:

if (message.content === "foo") message.channel.sendMessage("bar");

Do:

var responses = {"foo": "bar"};
if (responses[message]) message.channel.sendMessage(responses[message]);

It may be more complicated for shorter stacks of if else statements but it is more efficient for large ones like the one in your code.