'TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function

I have this little problem here:

events.js:200
throw new errors.ERR_INVALID_ARG_TYPE('listener', 'Function', listener);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type undefined
at _addListener (events.js:200:11)
at Client.addListener (events.js:259:10)
at Object. (D:\Yoshio\index.js:7:5)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)

I searched for answers but I couldn't find any, please tell me what to do.
Here is my code:

const Discord = require("discord.js");

const TOKEN = "mytoken";

var bot = new Discord.Client();

bot.on("message"), function(message) {
  console.log(message.content);
};

bot.login(TOKEN);


Solution 1:[1]

From the code you submitted, you are closing your on call before passing the function as an argument. Try this instead:

const Discord = require("discord.js");

const TOKEN = "mytoken"

var bot = new Discord.Client();

/*
 * Note the change here, the parenthesis is moved after
 * the function declaration so your anonymous function is now
 * passed as an argument.
 */
bot.on("message", function(message) {
  console.log(message.content);
});

bot.login(TOKEN);

Solution 2:[2]

bot.on("message"), function(message) {
  console.log(message.content);
};

The Error here shows that you are not passing a callback function to the event 'message'.

The reason here is syntax error, you are closing bracket before passing the callback method.

Solution:

bot.on("message", function(message) {
  console.log(message.content);
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrew Lively
Solution 2 Serdar D.