'TypeError: Cannot read properties of undefined (reading 'set') (discord.js)

Im trying to make a discord music bot and i have to admit that i dont have much knowledge on javascript so im just following a tutorial. Now this is the code he wrote

const slashFiles = fs.readdirSync("./slash").filter(file => file.endsWith(".js"))
for (const file of slashFiles){
    const slashcmd = require(`./slash/${file}`)
    client.toLocaleLowerCase.set(slashcmd.data.name, slashcmd)
    if (LOAD_SLASH) commands.push(slashcmd.data.toJSON())
}

and thats the error im getting

 client.toLocaleLowerCase.set(slashcmd.data.name, slashcmd)
                             ^

TypeError: Cannot read properties of undefined (reading 'set')
    at Object.<anonymous> (C:\Users\stelj\Desktop\bot\main.js:31:30)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

Pls help



Sources

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

Source: Stack Overflow

Solution Source