Welcome to StackOverflow, ReverseAlpha!
Shawn's answer is correct, but I would like to expand upon it.
It's possible that your bot's request to reply to the message (the promise sent by Discord.js to the API) succeeds after the request to delete that message, and once the message is deleted you can't reply to it. If you really wanted to delete the original message after replying, you could use async/await to wait for the message reply to complete, and then delete the original message.
Besides, you're listening on the message
event while since Discord.js v13 the event has been renamed to messageCreate
.
I've rewritten your code to fix these changes (and also a small spelling error, I tend to do that)
client.on('messageCreate', async msg => {
console.log("Message received.")
if (msg.content === 'ping') {
await msg.reply("pong")
await msg.delete()
}
});
Hope it helps!