Question:
Why is my Ping Slash Command code not partially working?
Repl link:
MEE10
code snippet:
MEE10/ping.js
Question:
Why is my Ping Slash Command code not partially working?
Repl link:
MEE10
code snippet:
MEE10/ping.js
Hey, @NathanielWood1 welcome to the forums.
Where is msg
declared?
const latency = msg.createdTimestamp - message.createdTimestamp;
Here is the error im getting whenever I try to run the command:
TypeError: Cannot read properties of undefined (reading 'createdTimestamp')
at Object.module.exports.run (/home/runner/MEE10/src/commands/Utility/ping.js:33:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
I see let me look. I am assuming you are using discord.js v13
Took a look at the documentation and I think you are supposed to use message.createdTimestamp
instead of msg.createdTimestamp
.
Also, why would you subtract it from itself? You could use the following.
new Date().getTime()
And then subtract the message time from it.
alright, I’ll try that, thanks!
Now I am getting another error when running the ping command itself
ReferenceError: client is not defined
at Object.module.exports.run (/home/runner/MEE10/src/commands/Utility/ping.js:37:33)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
I may be wrong on this one but client
on line 23 may be a local variable so you can only use it within the try
statement. And that’s why you are getting an error on line 37.
The command is working now.
@NathanielWood1 it looks like our wonderful community members were able to help resolve this question for you! I’ll close this thread now.