title: Discord.js | You can only bulk delete messages that are under 14 days old
body: <p>if there's messages over 14 days old and some that aren't 14 days old it does not delete the messages that aren't 14 days old and it sends an error is there a way to delete the messages that are not over 14 days old and leave the ones that are over 14 days old if you can't then can you help me make it stop sending an error and make it send a message saying &quot;You can only bulk delete messages that are under 14 days old.&quot; in the channel instead of it showing a error in the console thanks.</p>
  <pre><code>const { Message } = require(&quot;discord.js&quot;);
  const Client = require(&quot;../structures/Client&quot;);
  module.exports = {
    name: `clear`,
    /**
     * @param {Client} client
     * @param {Message} message
     * @param {String[]} args
     */
    run: async (client, message, args) =&gt; {
  
      const msg = message;
      var amt = parseInt(args[0], 10);
  
      if(message.member.hasPermission(['MANAGE_MESSAGES'])) {
        if(!amt) {
          msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
        } else {
          if(amt &gt; 100) {
            return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per command` }))
          } else {
            if(amt == 100) {
              msg.channel.bulkDelete(amt);
              msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m =&gt; { m.delete({ timeout: 3000 }); }).catch(err =&gt; { console.log(err); })
            } else {
              msg.channel.bulkDelete(amt + 1);
              msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m =&gt; { m.delete({ timeout: 3000 }); }).catch(err =&gt; { console.log(err); })
            }
          }
        }
      } else {
        if(message.member.hasPermission(['ADMINISTRATOR'])) {
          if(!amt) {
            msg.channel.send(client.embed({ description: `${msg.author.username}! Please specify a amount of messages to delete`}));
          } else {
            if(amt &gt; 100) {
              return message.channel.send(client.embed({ description: `You can only clear minimum of 100 messages per command` }))
            } else {
              if(amt == 100) {
                msg.channel.bulkDelete(amt);
                msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m =&gt; { m.delete({ timeout: 3000 }); }).catch(err =&gt; { console.log(err); })
              } else {
                msg.channel.bulkDelete(amt + 1);
                msg.channel.send(client.embed({ description: `${msg.author.username}! You cleared ${amt} messages`})).then(m =&gt; { m.delete({ timeout: 3000 }); }).catch(err =&gt; { console.log(err); })
              }
            }
          }
        } else {
          msg.channel.send(client.embed({ description: `${msg.author.username}! You do not have permission to run that command.`}));
        }
      }
  
  
  
    },
    timeout: 1500
  }
  </code></pre>