Discord.js TypeError: Cannot read property 'send' of undefined

When Using The p!ping Command It Sends Me that error

TypeError Cannot read property 'send' of undefined

Here’s the code

const { Message } = require("discord.js")

module.exports = {
    name : 'ping',
    description : 'Pong!',
    execute(message, args) {
        message.channel.send("Pong!")
    }
}

There is no way to see the issue with that section of the code. It tends to indicate that whatever made the call to execute did not send the message as a parameter.

The single best thing you can do is get into the habit of debugging your assumptions. Place a console.log(message) statement above the send and see if it has a value. The ping/pong example is common all over the place as well so you can compare your code with an online example and determine what is different.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.