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

339
Vistas
I am trying to make a discord.js ping command with latency but it shows this error

I am trying to make a ping command which shows the latency too but I face a error and I don't know why it is showing it, this is the error -

TypeError: Cannot read properties of undefined (reading 'ping')
    at Object.execute (C:\Users\Ayush Kumar\Desktop\AniVenture\commands\utility\ping.js:10:74)
    at Client.<anonymous> (C:\Users\Ayush Kumar\Desktop\AniVenture\index.js:78:11)
    at Client.emit (node:events:390:28)
    at MessageCreateAction.handle (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\websocket\WebSocketManager.js:350:31)
    at WebSocketShard.onPacket (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
    at WebSocketShard.onMessage (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
    at WebSocket.onMessage (C:\Users\Ayush Kumar\Desktop\AniVenture\node_modules\ws\lib\event-target.js:199:18)      
    at WebSocket.emit (node:events:390:28)

Code in ping.js -

const Discord = require("discord.js");

module.exports = {
name: 'ping',  
cooldown: 4,
execute(message, client) {
    const bot = message.createdTimestamp - Date.now();
    const ping = new Discord.MessageEmbed()
    .setTitle("Pong! :ping_pong:")
    .setDescription(`Bot latency: \`${bot}ms\`\n API latency: \`${client.ws.ping}ms\``)
    .setColor("#31e8b7")
    .setTimestamp()
    .setFooter(`${message.author.tag}`);
    message.channel.send({ embeds: [ping] });
},
};

I am using discord.js v13, please tell me how do I fix this error, Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Swap your (message, client) with (client, message)

execute(client, message) {
    const bot = message.createdTimestamp - Date.now();
    const ping = new Discord.MessageEmbed()
    .setTitle("Pong! :ping_pong:")
    .setDescription(`Bot latency: \`${bot}ms\`\n API latency: \`${client.ws.ping}ms\``)
    .setColor("#31e8b7")
    .setTimestamp()
    .setFooter(`${message.author.tag}`);
    message.channel.send({ embeds: [ping] });
},
};
about 4 years ago · Juan Pablo Isaza Denunciar
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