title: Discord.js - TypeError: "listener" argument must be a function
body: <h2>This is my Discord bot code:</h2>
  
  <pre><code>const Discord = require('discord.js');
  const client = new Discord.Client();
  const token = require('./settings.json').token;
  
  client.on('ready',() =&gt; {
      console.log('\n\nI\'m Online, mate.\nVery online, indeed.\n');
  });
  // Showing (in console) that the bot is online.
  
  
  
  var prefix = "-"
  client.on('message', message =&gt; { // Messaging stuff - Chat commands etc.
  
      if (!message.content.startsWith(prefix)) return;
  
      console.log('A command was found.')
  
      let args = message.content.split(' ').slice(1);
      var argresult = args.join(' ');
  
      if (message.author.bot) return;
      // If bot is the author (prevent selfbot.)
  
  
  
      if (message.content.startsWith(prefix + 'moffa')) { // Checks if bot is online and shows latency.
          message.channel.send(`**MOFFA!!** \`${Date.now() - message.createdTimestamp} ms delay.\``);
      } else
  
  
  
      if (message.content.startsWith(prefix + 'moos')) { // Cross-server messaging.
          client.channels.get('censored').send('Cross-channel typing is working, yes.');
          message.channel.send('Look in &lt;#censored&gt;.')
      } else
  
  
  
      if (message.content.startsWith(prefix + 'sg')) { // Set game.
          if (!argresult) argresult = null;
          client.user.setActivity(argresult)
          message.channel.send('Set `' + argresult + '` as activity.')
      } else
  
  
  
      if (message.content.startsWith(prefix + 'ss')) { // Set status.
          if(!argresult) argresult = 'online';
          client.user.setStatus(argresult);
          message.channel.send('Updated status.')
      } else
  
  
  
      if (message.content.startsWith(prefix + 'fnname')) { // Sends censored's name on Fortnite.
          message.channel.send('`censored` is &lt;@!censored&gt;\'s name on Fortnite');
      } else
  
  
  
      if (message.content.startsWith(prefix + 'commands')) { // Shows a message with all commands. Update manually.
          message.channel.send('All the current commands are: `moffa`, `fnname` &amp; `commands`. Ex. use: `' + prefix + 'moffa`.');
      }
  });
  
  
  client.login(token);
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>PS C:\Users\censored\Documents\Code\nodejs\discord bot 2&gt; nodemon
  [nodemon] 1.17.1
  [nodemon] to restart at any time, enter `rs`
  [nodemon] watching: *.*
  [nodemon] starting `node app.js`
  events.js:239
      throw new TypeError('"listener" argument must be a function');
      ^
  
  TypeError: "listener" argument must be a function
      at _addListener (events.js:239:11)
      at Client.addListener (events.js:297:10)
      at Object.&lt;anonymous&gt; (C:\Users\censored\Documents\Code\nodejs\discord bot 2\app.js:7:8)
      at Module._compile (module.js:643:30)
      at Object.Module._extensions..js (module.js:654:10)
      at Module.load (module.js:556:32)
      at tryModuleLoad (module.js:499:12)
      at Function.Module._load (module.js:491:3)
      at Function.Module.runMain (module.js:684:10)
      at startup (bootstrap_node.js:187:16)
  [nodemon] app crashed - waiting for file changes before starting...
  </code></pre>
  
  <p>It does not specify where the error is, or how to fix it.</p>
  
  <p>I am using Atom (newest version.)
  Nodemon is something that allows me to bypass having to open and close the terminal for each time I refresh the bot.
  It worked fine, until I tried to make a rich embed command.
  When I removed the command I got this error.
  Well, I got it while I was making it too.</p>
  
  <p><strong>Help would be appreciated. Thanks!</strong></p>