Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda