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

248
Vistas
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 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