Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
how to remove this comma in the status
bot.on('message', message => {
if (message.content.startsWith('ch ')){
        a = message.content
        let str1= a
        let str2= 'ch '
        str3 = str1.split(str2)
        var str4 = str3.toString()
            bot.user.setActivity( { type: 'WATCHING' } , {name:str4} )
    }
})

When I type "ch book", it become this : enter image description here a comma in front of the word.

How can I fix this? Thanks

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Looks like you are simply trying to remove "ch " from the beginning of the string. You don't need split and arrays for that, you can just use .replace() :

bot.on('message', message => {
    if (message.content.startsWith('ch ')){
        bot.user.setActivity( { type: 'WATCHING' } , { name:message.content.replace('ch ','') })
    }
})
about 4 years ago · Juan Pablo Isaza Report

0

String.prototype.split()

You should first understand the usage of this method first. This method splits a string into an array with each element delimited by the character of your choice, here a comma.

"ch, books".split(','); // returns ["ch", " books"]

Array.prototype.toString()

This method returns a string representation of the array, which would have comma-separated elements and you end up going back to square one!

["ch", " books"].toString(); // returns "ch, books"

Use String.prototype.replace() Instead

As long as you need to just sanitize string by removing commas or other special characters, use this method along with RegExp.

"ch, books, copies, notebooks".replace(/,/g, ''); // returns "ch books copies notebooks"

// further remove more characters such as hyphens
"ch, books, copies, note-books".replace(/,|-/g, ''); // returns "ch books copies notebooks"
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!