Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda