'DiscordJS interactionCreate and messageCreate not working

I know this and this post both have similar titles but the solution to both is not working for me.

As you can see in my code below I've used Intents.FLAGS.GUILD_MESSAGES to create the client variable but it doesn't give any output in my console when I do the /ping command that I made. /ping however is available in when typing "/" in chat.

const { clientId, token, testGuildId } = require('./config.json');
const Discord = require('discord.js');
const fs = require('fs');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');

const client = new Discord.Client({ 
    intents: [
        Discord.Intents.FLAGS.GUILDS,
        Discord.Intents.FLAGS.GUILD_MESSAGES,
        Discord.Intents.FLAGS.DIRECT_MESSAGES,
    ],
});

const commandFiles = fs.readdirSync(`./Commands/commandScripts`).filter(file => file.endsWith(".js"));

//for
const commandsArray = [];
client.commandsArray = new Discord.Collection();
for (const file of commandFiles){
    const newCommand = require(`./Commands/commandScripts/${file}`);
    commandsArray.push(newCommand.data.toJSON());
    client.commandsArray.set(newCommand.data.name, newCommand);
}

client.once('ready', async () => {

    const rest = new REST({
        version: "9"
    }).setToken(token);

    (async () => {
        try {
            if(process.env.ENV === "production"){
                await rest.put(Routes.applicationCommands(clientId), {
                    body: commandsArray,
                });
                console.log("Successfully registered commands globally.");
            } else {
                var temp = await rest.put(Routes.applicationGuildCommands(clientId, testGuildId), {
                    body: commandsArray,
                });
                console.log(temp);
                console.log("Successfully registered commands locally.");
            }
        } catch (err) {
            if(err) console.error(err);
        }
    })();
    console.log(`[${time}] *** Bot Is Ready On Discord!`);

});
client.on('interactionCreate', async interaction => {
    console.log(interaction);
});

client.on("messageCreate", (message) => {
    console.log(message.content);
})

client.login(token);

My package.json:

{
  "name": "excavator",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "@discordjs/builders": "^0.12.0",
    "@discordjs/opus": "^0.3.3",
    "@discordjs/rest": "^0.3.0",
    "axios": "^0.21.1",
    "discord-api-types": "^0.27.3",
    "discord.js": "^12.5.3",
    "ffmpeg-static": "^4.2.7",
    "fs": "0.0.1-security",
    "mongoose": "^5.13.14",
    "path": "^0.12.7",
    "simple-youtube-api": "^5.2.1",
    "yt-search": "^2.5.1",
    "ytdl-core": "^4.4.5",
    "ytdl-core-discord": "^1.2.5"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "ExcanatorGames",
  "license": "ISC"
}


Solution 1:[1]

Figured out the problem. I needed to uninstall discord.js and reinstall discord.js

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ExcanatorGames