-7

Here is my code:

if (message.content.startswith(prefix+'ping')) {
    message.channel.sendmessage('pong! \'${date.now() -message.createdtimemestamp} ms\'');
} else

It gives me an error

TypeError: message.content.startswith is not a function

What is the solution to this problem?

Pritt Balagopal
  • 1,476
  • 2
  • 18
  • 32
Mark Ehab
  • 9
  • 1
  • 1
  • 3

1 Answers1

3

Easy. You have misspelt startsWith(). Notice that the letter "W" is in capital. In fact, when naming variables in Javascript, compounded words are capitalized except for the first one. This also applies for sendMessage(), but do not use it as that's deprecated, use send() instead. So you are supposed to do:

if(message.content.startsWith(prefix + 'ping')) {
    message.channel.send('Pong!' + `${date.now() -message.createdtimemestamp} ms`);
}
Pritt Balagopal
  • 1,476
  • 2
  • 18
  • 32