Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

(node:8604) DeprecationWarning: The message event is deprecated. Use messageCreate instead (Use `node –trace-deprecation …`

I have been trying to make a discord bot and every time, my bot sends something in the chat, I get this error written in the title in the console.

My code:

client.on('message', (message) => {
    if (!message.content.startsWith(prefix) || message.author.bot) return

    const args = message.content.slice(prefix.length).split(/ +/)
    const command = args.shift().toLowerCase()

    if (command === 'ping') {
        message.channel.send('pong!')
    } else if (command === 'turn-off') {
        if (message.author.id === '000000000000000000') {
            message.channel.send('Shutting down...')
            let interval0 = setInterval(turnOff, 1000)

            function turnOff() {
                clearInterval(interval0)
                console.log('Shutting down...')
                client.destroy()
            }
        } else {
            message.channel.send(
                "You don't have required permissions to use this command!"
            )
        }
    }
})

I tried replacing "message" to "messageCreate" on the part where it was sending something in chat, or even replacing every "message" with "messageCreate".

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Does anybody know what the issue could be?

>Solution :

You should listen to the messageCreate event instead of the message event:

client.on('messageCreate', message => {
  /* ... */
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading