Cannot read properties of undefined (reading 'reply')

I want to create a latency (ping) command, but I got an error message like this : Cannot read properties of undefined (reading 'reply'). How to fix this problem?
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('latency')
.setDescription('Checking the Roundtrip Latency & WebSocket connection in miliseconds'),
async execute(client, interaction) {
const sent = await interaction.reply({ content: 'Measuring...', fetchReply: true });
interaction.editReply(`\`Client: ${sent.createdTimestamp - interaction.createdTimestamp}\` ms | WebSocket: ${client.ws.ping}`);
}
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('latency')
.setDescription('Checking the Roundtrip Latency & WebSocket connection in miliseconds'),
async execute(client, interaction) {
const sent = await interaction.reply({ content: 'Measuring...', fetchReply: true });
interaction.editReply(`\`Client: ${sent.createdTimestamp - interaction.createdTimestamp}\` ms | WebSocket: ${client.ws.ping}`);
}
};
3 Replies
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Syjalo
Syjalo16mo ago
console.log(client.constructor.name)
Catharsis
Catharsis16mo ago
thank you very much!