title: Delete message command for moderators
body: <p>I am working on a Discord bot and has been reading the API lately. I want to add a command for my bot which will clear a text channel entirely, and will only allow people with a permission to manage messages.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>client.on('message', function(message) {
      if (message.content == "^clear") {
          try {
              if (message.member.hasPermission("MANAGE_MESSAGES")) {
                  messages = message.channel.fetchMessages();
                  message.channel.bulkDelete(messages);
              }
          } catch(e) {
              message.channel.send("ERROR: ERROR CLEARING CHANNEL.");
              console.log(e);
          }
      }
  
  });
  </code></pre>
  
  <p>I get an error which looks like this:</p>
  
  <pre><code>TypeError: The messages must be an Array, Collection, or number.
  at TextChannel.bulkDelete (/Users/person/bot/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:379:11)
  at Client.&lt;anonymous&gt; (/Users/person/bpt/bot.js:29:33)
  at emitOne (events.js:96:13)
  at Client.emit (events.js:188:7)
  at MessageCreateHandler.handle (/Users/person/bot/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
  at WebSocketPacketManager.handle (/Users/person/bot/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:102:65)
  at WebSocketConnection.onPacket (/Users/person/bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:325:35)
  at WebSocketConnection.onMessage (/Users/person/bot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:288:17)
  at WebSocket.onMessage (/Users/person/bot/node_modules/discord.js/node_modules/ws/lib/EventTarget.js:103:16)
  at emitTwo (events.js:106:13)
  </code></pre>