interaction.client.commands.get is not a function error in discord.js

I have followed the documents to create my first discord.js bot (Ive always used discord.py) and I have run into an error regarding one of the functions within the documented code.
I have attempted to use the following block of code for running the command builder commands from other files. I have surrounded the error line in the code with comments

client.on(Events.InteractionCreate, async interaction => {
    if (!interaction.isChatInputCommand()) return;
//////////////////////////////////////////////////////////////////////////////////
    const command = interaction.client.commands.get(interaction.commandName);
//////////////////////////////////////////////////////////////////////////////////
    if (!command) {
        console.error(`No command matching ${interaction.commandName} was found.`);
        return;
    }

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        if (interaction.replied || interaction.deferred) {
            await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
        } else {
            await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
        }
    }
});

The error I have been getting is saying that interaction.client.commands.get is not a function, even though that is what discord.js has in their documents here. I just want to know how to solve this issue, as I have no clue what to do to solve it.