Return a value from variable (?)

I don’t know too much JS and I’m trying to return a value from a code for another thing to work.
(Basically, I’m using a module called aoi.js to make a discord bot, and I am trying to get the file count in a folder.)
I could only get this code to work, and it only logs to the console:

const fs = require('fs');
const dir = './commands/$getVar[category]';

fs.readdir(dir, (err, files) => {

I need to return (?) “files.length” as a raw text (?) instead of logging it.

Could anyone help me with this issue?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.