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

149
Visualizações
Discord Bot Issue - TypeError: Cannot read properties of null (reading 'id')

I'm getting the following error: TypeError: Cannot read properties of null (reading 'id') at /index.js:144:31. My index.js code is below:

if(interaction.customId == 'generateCode') {

        // defer
        await interaction.deferReply({ ephemeral: true });

        // already generated?
        data = JSON.parse(fs.readFileSync(`./system/index.json`));
*This is row 144, user.id is the issue*
        if(data.filter(t => t.id == interaction.user.id)[0]) {
            embed = new MessageEmbed()
                .setColor('DARK_BLUE')
                .setAuthor({ name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL() })
                .setDescription("`"+data.filter(t => t.id == interaction.user.id)[0].code+"`")
            await interaction.editReply({ embeds: [embed] });
            return
        }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The error is telling you that your user object is null. It looks like the data = JSON.parse(fs.readFileSync()) is not pulling in the file.

Based on this: JSON.parse(fs.readFileSync()) returning a buffer - string of numbers readFileSync returns a buffer if you don't add an encoding.

data = JSON.parse(fs.readFileSync(`./system/index.json`, 'utf8'))
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