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

250
Visualizações
My command goes through but doesnt seem to work (doesn't delete)

I made a bot with some help, I am a new dev so I don't know much. But when I do $redeemkey 12345678 it seems to go through (the bot replies back and console says "true") But one part doesn't work. The part where it deletes the argument from the txt file. Any help is appreciated here is my script:

    if (command === '$redeemkey') {
        
        const fs = require('fs')
        const haspath = `whitelisted/${message.author.id}.txt`;
        if (fs.existsSync(haspath)) return message.reply({
          embeds: [
              new MessageEmbed()
              .setColor('RED')
              .setDescription(`You're already whitelisted!`)
          ]
      });
      fs.readFile('notredeemed.txt', function (err, data) {
      if (data.toString().match(new RegExp(`^${args[0]}$`, "m"))) {
                const match = new RegExp(`(\n|^)${args[0]}(\r|$)`)
              
                const newFile = data.toString().replace(match, '')
                fs.writeFile('notredeemed.txt', newFile, "utf8", function (err) {
                  if (err) return console.log(err)
                  console.log("true")
                })
            }
              })
}

Thanks!

about 4 years ago · Juan Pablo Isaza
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