@ad1m/djb
Version:
A streamlined library for creating Discord bots with Discord.js, featuring a simple command and event handler structure.
63 lines (61 loc) • 2.13 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/utils/url.ts
var url_exports = {};
__export(url_exports, {
getAppPath: () => getAppPath,
getCurrenDir: () => getCurrenDir,
getCurrentModuleType: () => getCurrentModuleType
});
module.exports = __toCommonJS(url_exports);
var import_url = require("url");
var import_path = require("path");
var import_fs = require("fs");
var import_meta = {};
var getCurrentModuleType = () => {
if (typeof __dirname !== "undefined") {
return "cjs";
} else if (typeof import_meta?.url !== "undefined") {
return "esm";
} else {
throw new Error("Unable to determine module type.");
}
};
var getCurrenDir = () => {
const mType = getCurrentModuleType();
switch (mType) {
case "cjs":
return __dirname;
case "esm":
return (0, import_path.dirname)((0, import_url.fileURLToPath)(import_meta.url));
}
};
var getAppPath = () => {
const distAppPath = (0, import_path.resolve)(process.cwd(), "dist", "app");
const appPath = (0, import_path.resolve)(process.cwd(), "app");
if ((0, import_fs.existsSync)(distAppPath)) return distAppPath;
else if ((0, import_fs.existsSync)(appPath)) return appPath;
else throw new Error("No /app directory found.");
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getAppPath,
getCurrenDir,
getCurrentModuleType
});