title: make the error send in channel instead of the console so the program wont stop running
body: <p>I am currently having a problem about my signup command and when  searched about the error I am having which is:
  <code>MongoServerError: E11000 duplicate key error collection: ShinDB.users index: username_1 dup key: { username: &quot;Shin&quot; }</code></p>
  <p>they always say to drop the collection which I don't want.</p>
  <p>what i want is for example i wrote <code>'&gt;signup Shin thisisatest@1234'</code> and if the <code>'Shin'</code> username is already in the username database it will NOT send the <code>'MongoServerError'</code> in the console but instead it will send an error <code>'That username already exist'</code> in the channel which the user send it to.</p>
  <p><strong>Signup Command:</strong></p>
  <pre class="lang-js prettyprint-override"><code>var strongRegex = new RegExp(&quot;^(?=.{14,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$&quot;, &quot;g&quot;);
  var mediumRegex = new RegExp(&quot;^(?=.{10,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$&quot;, &quot;g&quot;);
  var enoughRegex = new RegExp(&quot;(?=.{8,}).*&quot;, &quot;g&quot;);
  var specialChar = /[`!@#$%^&amp;*()_+\-=\[\]{};':&quot;\\|,.&lt;&gt;\/?~]/;
  const User = require('../../Database/models/user')
  
  module.exports = {
      name: &quot;signup&quot;,
      description: &quot;Signup for an Economy Account&quot;,
      usage: &quot;&gt;signup&quot;,
      aliases: [],
      run: async (client, message, args) =&gt; {
          //message is inguild
          if (message.inGuild()) {
              return message.reply({ content: `This command can only be used in &lt;@${client.user.id}&gt; DM.\n\`\`Usage: &gt;signup &lt;username&gt; &lt;password&gt;\`\`\n\`\`Note: Your Economy Account is Safe\`\`` })
          }
  
          //message is in DM
          if (message.channel.type === 'DM') {
              
              // USERNAME
              const userargs = args[0]
              const pass = args[1]
  
              if (!userargs) {
                  return message.reply({ content: '**Please provide a username for your Economy Account!\n``Correct Usage: &gt;signup &lt;username&gt; &lt;password&gt;``**' })
              }
  
              const userToLow = userargs.toLowerCase()
              const user = userToLow.charAt(0).toUpperCase() + userToLow.substring(1, userToLow.length)
              
              if (user.length &lt; 3) return message.reply({ content: '**[__Too Short__]** **Your Username must have atleast 3 Characters**' })
              if (user.length &gt; 7) return message.reply({ content: '**[__Too Long__]** **You Username must only have 7 Characters**' })
              if (specialChar.test(user)) {
                  return message.reply({ content: '**Username\'s must not have any Special Characters**' })
              }
  
              // PASSWORD
              let str
              let med
              let weak
              if (strongRegex.test(pass)) {
                  str = 'Strong'
              }
              if (mediumRegex.test(pass)) {
                  med = 'Medium'
              }
              if (!strongRegex.test(pass) &amp;&amp; !mediumRegex.test(pass)) {
                  weak = 'Weak'
              }
  
              if (!pass) return message.reply({ content: '**Please provide a password for your Economy Account!**' })
              if (pass.length &lt; 8) return message.reply({ content: '**[__Too Short__]** **Your Password must have atleast 8 Characters**' })
  
              // CREATING THE ACCOUNT
              User.findOne({ createdBy: message.author.id }, async (err, data) =&gt; {
                  if (data) {
                      return message.reply({ content: `**You already have made an Account and the Username of the Account that you made is: \`\`${data.username}\`\`\n\`\`Note: if you forget your password you can just run the command &gt;recoveraccount\`\`**` })
                  } else if (err) {
                      return message.reply({ content: 'That username already exist' })
                  } else {
                      new User({
                          loggedInOn: &quot;0&quot;,
                          createdBy: message.author.id,
                          isLoggedIn: false,
                          username: user,
                          password: pass,
                      }).save()
                      return message.reply({ content: 'You have successfuly made an Economy Account!'})
                  }
  
              })
  
          }
      }
  }
  </code></pre>
  <p><strong>User Schema/Model:</strong></p>
  <pre class="lang-js prettyprint-override"><code>const mongoose = require('mongoose')
  
  const userSchema = new mongoose.Schema({
      loggedInOn: String,
      createdBy: String,
      isLoggedIn: Boolean,
      username: {
          type: String,
          unique: true
      },
      password: String
  })
  
  module.exports = mongoose.model('Users', userSchema)
  </code></pre>
  <p><strong>Full Error:</strong></p>
  <pre class="lang-js prettyprint-override"><code>                return callback(new error_1.MongoServerError(res.writeErrors[0]));
                                  ^
  
  MongoServerError: E11000 duplicate key error collection: ShinDB.users index: username_1 dup key: { username: &quot;Shin&quot; }
      at C:\Users\Lenovo\Desktop\Shinomy\node_modules\mongoose\node_modules\mongodb\lib\operations\insert.js:53:33
      at C:\Users\Lenovo\Desktop\Shinomy\node_modules\mongoose\node_modules\mongodb\lib\cmap\connection_pool.js:273:25
      at handleOperationResult (C:\Users\Lenovo\Desktop\Shinomy\node_modules\mongoose\node_modules\mongodb\lib\sdam\server.js:327:20)
      at Connection.onMessage (C:\Users\Lenovo\Desktop\Shinomy\node_modules\mongoose\node_modules\mongodb\lib\cmap\connection.js:215:9)
      at MessageStream.&lt;anonymous&gt; (C:\Users\Lenovo\Desktop\Shinomy\node_modules\mongoose\node_modules\mongodb\lib\cmap\connection.js:63:60)
      at MessageStream.emit (node:events:527:28)
      at processIncomingData (C:\Users\Lenovo\Desktop\Shinomy\node_modules\mongoose\node_modules\mongodb\lib\cmap\message_stream.js:108:16)
      at MessageStream._write (C:\Users\Lenovo\Desktop\Shinomy\node_modules\mongoose\node_modules\mongodb\lib\cmap\message_stream.js:28:9)
      at writeOrBuffer (node:internal/streams/writable:389:12)
      at _write (node:internal/streams/writable:330:10) {
    index: 0,
    code: 11000,
    keyPattern: { username: 1 },
    keyValue: { username: 'Shin' },
    [Symbol(errorLabels)]: Set(0) {}
  }
  </code></pre>
  <p><strong>My Database Current Collections:</strong></p>
  <p><a href="https://i.stack.imgur.com/5o5c4.png" rel="nofollow noreferrer">Collections Picture</a></p>
  <p>i hope i have explained it very well, any help would be really appreciated. thanks.</p>