How do I fix my discord.js music bot code?

So, Im making a discord.js music bot, and then it said `client.commands.set(command.data.name, command);
^

TypeError: Cannot read properties of undefined (reading ‘name’)`
and this is my code:

const client = new Client({
    intents: 32767
});

// List of all commands
const commands = [];
client.commands = new Collection();

const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles)
{
    const filePath = path.join(commandsPath, file);
    const command = require(filePath);

    client.commands.set(command.data.name, command);
    commands.push(command.data.toJSON());
}

So, im not really sure whats happening but if you want the discord.js version, its version 14.9.0.