-2

I used backticks yet the string interpolation is not working, what's even weirder is that it is sometimes working in other parts of the code.

It's not working here

let files = getFiles(`./commands/${category}`, ".js")

But it is working here

if (reload)
    delete require.cache[require.resolve(`./commands/${category}/${f}`)]

this is the error I'm getting

let files = getFiles(`./commands/${category}`, ".js")
                                           ^

ReferenceError: category is not defined
Nikhil
  • 81
  • 7
Ancient
  • 41
  • 1
  • 5

1 Answers1

1

The error you got (ReferenceError: category is not defined), shows that the variable category is not defined in the scope of that line. Make sure that if you're using let, the variable isn't defined within an inner-block, such as a loop for a if-statement. See more here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let

Michael M.
  • 10,486
  • 9
  • 18
  • 34