async function importDirectory(
  path,
) {
  path = path.replaceAll("\\", "/");
  const files = Deno.readDirSync(Deno.realPathSync(path));
  const folder = path.substring(path.indexOf("/src/") + 5);
  if (!folder.includes("/")) log.info(`Loading ${folder}...`);
  for (const file of files) {
    if (!file.name) continue;
    const currentPath = `${path}/${file.name}`;
    if (file.isFile) {
      if (!currentPath.endsWith(".ts")) continue;
      paths.push(
        `import "${
          Deno.mainModule.substring(0, Deno.mainModule.lastIndexOf("/"))
        }/${
          currentPath.substring(currentPath.indexOf("src/"))
        }#${uniqueFilePathCounter}";`,
      );
      continue;
    }
    await importDirectory(currentPath);
  }
  uniqueFilePathCounter++;
}
/** This function allows reading all files in a folder. Useful for loading/reloading commands, monitors etc */
This function allows reading all files in a folder. Useful for loading/reloading commands, monitors etc
This function allows reading all files in a folder . Useful for loading / reloading commands monitors etc
async function importDirectory(
  path,
) {
  path = path.replaceAll("\\", "/");
  const files = Deno.readDirSync(Deno.realPathSync(path));
  const folder = path.substring(path.indexOf("/src/") + 5);
  if (!folder.includes("/")) log.info(`Loading ${folder}...`);
  for (const file of files) {
    if (!file.name) continue;
    const currentPath = `${path}/${file.name}`;
    if (file.isFile) {
      if (!currentPath.endsWith(".ts")) continue;
      paths.push(
        `import "${
          Deno.mainModule.substring(0, Deno.mainModule.lastIndexOf("/"))
        }/${
          currentPath.substring(currentPath.indexOf("src/"))
        }#${uniqueFilePathCounter}";`,
      );
      continue;
    }
    await importDirectory(currentPath);
  }
  uniqueFilePathCounter++;
}
async function importDirectory ( path , ) { path = path . replaceAll ( "\\" , "/" ) ; const files = Deno . readDirSync ( Deno . realPathSync ( path ) ) ; const folder = path . substring ( path . indexOf ( "/src/" ) + 5 ) ; if ( ! folder . includes ( "/" ) ) log . info ( ` ${ folder } ` ) ; for ( const file of files ) { if ( ! file . name ) continue ; const currentPath = ` ${ path } ${ file . name } ` ; if ( file . isFile ) { if ( ! currentPath . endsWith ( ".ts" ) ) continue ; paths . push ( ` ${ Deno . mainModule . substring ( 0 , Deno . mainModule . lastIndexOf ( "/" ) ) } ${ currentPath . substring ( currentPath . indexOf ( "src/" ) ) } ${ uniqueFilePathCounter } ` , ) ; continue ; } await importDirectory ( currentPath ) ; } uniqueFilePathCounter ++ ; }
This function allows reading all files in a folder.
This function allows reading all files in a folder .