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

180
Visualizações
discord.js v13 - TypeError: no se pueden leer las propiedades de undefined (leyendo 'tiempo de actividad')

Estoy creando un bot discord.js v13 con un controlador de comandos de barra diagonal, recibo un error de TypeError: Cannot read properties of undefined (reading 'uptime') .

Aquí está mi código:

 const { SlashCommandBuilder } = require("@discordjs/builders"); module.exports = { data: new SlashCommandBuilder() .setName("uptime") .setDescription("Check how long the bot has stayed on!"), async execute(interaction, client) { let totalSeconds = client.uptime / 1000; let days = Math.floor(totalSeconds / 86400); let hours = Math.floor(totalSeconds / 3600); totalSeconds %= 3600; let minutes = Math.floor(totalSeconds / 60); let seconds = totalSeconds % 60; let roundedSeconds = Math.round(seconds); let uptime = `${days} days, ${hours} hours, ${minutes} minutes and ${roundedSeconds} seconds`; interaction.reply({ embeds: [ { color: "RANDOM", title: "**Uptime**", description: `It has been on for ${uptime}`, }, ], }); }, };

Esto es lo que definí client en mi archivo index.js:

 const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_TYPING, ], });
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Defina esto en un archivo de comando cuando use client :

 const { client } = interaction;
about 4 years ago · Juan Pablo Isaza Relatório

0

en index.js agregar module.exports = client;

y en uptime.js agregue const client = require('../../index.js')

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