Reputation: 25
I was trying code for ping and I end up like this.. new to coding any help will greatly be appreciated...
Here is the code:
module.exports = {
name: 'ping' ,
description: "this is a ping command.",
execute(message, arguments, client) {
message.reply('Calculating ping...').then((resultmessage) => {
const ping = resultmessage.createdtimestamp - message.createdtimestamp
resultmessage.edit(`Bot latency: ${ping}`)
})
}
}
am using command handler .. main code is.
if(command === 'ping'){
client.commands.get('ping').execute(message, args,client);
and here whats the output and its bad... Bot latency: NaN
Upvotes: 2
Views: 147
Reputation: 5174
That's because properties, in this case, createdtimestamp
, are case sensitive. So you need to replace createdtimestamp
with createdTimestamp
.
module.exports = {
name: 'ping' ,
description: "this is a ping command.",
execute(message,arguments,client){
message.reply('Calculating ping...').then((resultmessage) => {
const ping = resultmessage.createdTimestamp - message.createdTimestamp
resultmessage.edit(`Bot latency: ${ping}`)
})
}
}
Upvotes: 1