title: Ban outside server users in Discord.js 12.5.1
body: <p>I am trying to make a ban command that can ban someone using his ID and it works great, the problem is that when I try to ban a user that isn't on the server (using his ID) or only use 1 digit, the command doesn't work and the bot crashes. I think the problem is caused by the if statement but I'm not sure.</p>
  <p>Here's my code :</p>
  <pre><code>  let args = messageArray.slice(1);
  
    if(message.content.startsWith(prefix + 'ban')) {
        let toBan = message.guild.members.cache.get(args[0]) || message.mentions.members.first() || message.guild.members.cache.find(x =&gt; x.user.username.toLowerCase() === args.slice(0).join(&quot; &quot;) || x.user.username === args[0]);
        if(!args) return message.channel.send('You need to mention a user!')
        if (!message.member.hasPermission(&quot;VIEW_AUDIT_LOG&quot;)) return message.channel.send(&quot;You don't have enough permissions.&quot;)
        if (!message.guild.me.hasPermission(&quot;BAN_MEMBERS&quot;)) return message.channel.send(&quot;I don't have enought permissions.&quot;)
               if(!toBan.bannable) return message.channel.send(&quot;I can't ban that user!&quot;)
        if(toBan === message.author) return message.channel.send(&quot;No.&quot;)
        if(toBan.roles.highest.position &gt;= message.member.roles.highest.position) return message.channel.send(&quot;You can't ban anyone that have a high or same role that you have.&quot;)
  
        const reason = args[1] || &quot;Undefined&quot;;
  
        member.ban(`${toBan}`, {
          reason: reason
        })
             message.channel.send(`${toBan} Has been banned of the server by ${message.author}!`)
         }
  </code></pre>