djs-builder
Advanced tools
Comparing version 0.1.3 to 0.1.4
import { ButtonManager } from './components/Buttons'; | ||
import { MenuManager } from './components/Menus'; | ||
import { PermissionChecker } from './permissions/perms'; | ||
declare const Components: { | ||
ButtonManager: typeof ButtonManager; | ||
MenuManager: typeof MenuManager; | ||
PermissionChecker: typeof PermissionChecker; | ||
}; | ||
export { Components }; | ||
export { ButtonManager, MenuManager, PermissionChecker }; | ||
//# sourceMappingURL=utils.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Components = void 0; | ||
exports.PermissionChecker = exports.MenuManager = exports.ButtonManager = void 0; | ||
const Buttons_1 = require("./components/Buttons"); | ||
Object.defineProperty(exports, "ButtonManager", { enumerable: true, get: function () { return Buttons_1.ButtonManager; } }); | ||
const Menus_1 = require("./components/Menus"); | ||
Object.defineProperty(exports, "MenuManager", { enumerable: true, get: function () { return Menus_1.MenuManager; } }); | ||
const perms_1 = require("./permissions/perms"); | ||
const Components = { | ||
ButtonManager: Buttons_1.ButtonManager, | ||
MenuManager: Menus_1.MenuManager, | ||
PermissionChecker: perms_1.PermissionChecker | ||
}; | ||
exports.Components = Components; | ||
Object.defineProperty(exports, "PermissionChecker", { enumerable: true, get: function () { return perms_1.PermissionChecker; } }); | ||
//# sourceMappingURL=utils.js.map |
@@ -6,3 +6,6 @@ import { Collection } from 'discord.js'; | ||
export declare const commandNames: Set<string>; | ||
export declare function readCommands(client: any, folderPath: string): Promise<number>; | ||
export declare function readCommands(client: any, prefix: { | ||
baseDir: any; | ||
path: string; | ||
}): Promise<number>; | ||
//# sourceMappingURL=prefix-register.d.ts.map |
@@ -33,15 +33,19 @@ "use strict"; | ||
exports.commandNames = new Set(); | ||
async function readCommands(client, folderPath) { | ||
async function readCommands(client, prefix) { | ||
let prefixCommandCount = 0; | ||
try { | ||
await fs_1.promises.access(folderPath); | ||
const files = await fs_1.promises.readdir(folderPath, { withFileTypes: true }); | ||
const resolvedPath = (0, path_1.resolve)(prefix.baseDir, prefix.path); | ||
console.log(`Processing directory: ${resolvedPath}`); | ||
await fs_1.promises.access(resolvedPath); | ||
const files = await fs_1.promises.readdir(resolvedPath, { withFileTypes: true }); | ||
for (const file of files) { | ||
const filePath = (0, path_1.join)(folderPath, file.name); | ||
const filePath = (0, path_1.join)(resolvedPath, file.name); | ||
console.log(`Reading file: ${filePath}`); | ||
if (file.isDirectory()) { | ||
prefixCommandCount += await readCommands(client, filePath); | ||
prefixCommandCount += await readCommands(client, { baseDir: prefix.baseDir, path: filePath }); | ||
} | ||
else if (file.isFile()) { | ||
try { | ||
const command = await Promise.resolve(`${filePath}`).then(s => __importStar(require(s))); | ||
const commandModule = await Promise.resolve(`${filePath}`).then(s => __importStar(require(s))); | ||
const command = commandModule.default || commandModule; | ||
if (command && (command.execute || command.run)) { | ||
@@ -56,10 +60,14 @@ exports.commands.set(command.name, command); | ||
} | ||
command.description = command.description || "No description provided."; | ||
command.cooldown = command.cooldown || 1; | ||
command.usage = command.usage || "No usage information provided."; | ||
command.category = command.category || "Not categorized."; | ||
command.owner = command.owner || false; | ||
if (command.prefix) { | ||
const defaultCommand = { | ||
description: "No description provided.", | ||
cooldown: 1000, | ||
usage: "No usage information provided.", | ||
category: "Not categorized.", | ||
owner: false, | ||
...command | ||
}; | ||
if (defaultCommand.prefix) { | ||
prefixCommandCount++; | ||
} | ||
console.log(`Command '${command.name}' registered.`); | ||
} | ||
@@ -77,6 +85,7 @@ else { | ||
client.prefixSize = prefixCommandCount; | ||
console.log(`Total commands registered from directory ${resolvedPath}: ${client.prefixSize}`); | ||
return prefixCommandCount; | ||
} | ||
catch (error) { | ||
console.error(`Error reading directory: ${folderPath}`); | ||
console.error(`Error reading directory: ${prefix.path}`); | ||
console.error(error); | ||
@@ -83,0 +92,0 @@ return 0; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const login_1 = require("./login"); | ||
const prefix_register_1 = require("./prefix-register"); | ||
class Starter { | ||
@@ -23,2 +24,3 @@ async start(djs, options) { | ||
if (options.prefix) { | ||
await (0, prefix_register_1.readCommands)(djs, options.prefix); | ||
await (0, prefix_responder_1.loadPrefix)(djs, options.prefix); | ||
@@ -25,0 +27,0 @@ } |
import { Starter } from "./events-handler/starter"; | ||
import { Components } from './builder/utils'; | ||
export { Starter, Components }; | ||
import { ButtonManager, MenuManager, PermissionChecker } from './builder/utils'; | ||
export { Starter, ButtonManager, MenuManager, PermissionChecker }; | ||
//# sourceMappingURL=utils.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Components = exports.Starter = void 0; | ||
exports.PermissionChecker = exports.MenuManager = exports.ButtonManager = exports.Starter = void 0; | ||
const starter_1 = require("./events-handler/starter"); | ||
Object.defineProperty(exports, "Starter", { enumerable: true, get: function () { return starter_1.Starter; } }); | ||
const utils_1 = require("./builder/utils"); | ||
Object.defineProperty(exports, "Components", { enumerable: true, get: function () { return utils_1.Components; } }); | ||
Object.defineProperty(exports, "ButtonManager", { enumerable: true, get: function () { return utils_1.ButtonManager; } }); | ||
Object.defineProperty(exports, "MenuManager", { enumerable: true, get: function () { return utils_1.MenuManager; } }); | ||
Object.defineProperty(exports, "PermissionChecker", { enumerable: true, get: function () { return utils_1.PermissionChecker; } }); | ||
//# sourceMappingURL=utils.js.map |
@@ -1,12 +0,10 @@ | ||
import { Starter, Components } from "./discord/utils"; | ||
export { Starter, Components }; | ||
import { Starter, ButtonManager, MenuManager, PermissionChecker } from "./discord/utils"; | ||
export { Starter, ButtonManager, MenuManager, PermissionChecker }; | ||
declare const _default: { | ||
Starter: typeof Starter; | ||
Components: { | ||
ButtonManager: typeof import("./discord/builder/components/Buttons").ButtonManager; | ||
MenuManager: typeof import("./discord/builder/components/Menus").MenuManager; | ||
PermissionChecker: typeof import("./discord/builder/permissions/perms").PermissionChecker; | ||
}; | ||
ButtonManager: typeof ButtonManager; | ||
MenuManager: typeof MenuManager; | ||
PermissionChecker: typeof PermissionChecker; | ||
}; | ||
export default _default; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Components = exports.Starter = void 0; | ||
exports.PermissionChecker = exports.MenuManager = exports.ButtonManager = exports.Starter = void 0; | ||
const axios_1 = __importDefault(require("axios")); | ||
@@ -36,4 +36,6 @@ const path_1 = __importDefault(require("path")); | ||
Object.defineProperty(exports, "Starter", { enumerable: true, get: function () { return utils_1.Starter; } }); | ||
Object.defineProperty(exports, "Components", { enumerable: true, get: function () { return utils_1.Components; } }); | ||
exports.default = { Starter: utils_1.Starter, Components: utils_1.Components }; | ||
Object.defineProperty(exports, "ButtonManager", { enumerable: true, get: function () { return utils_1.ButtonManager; } }); | ||
Object.defineProperty(exports, "MenuManager", { enumerable: true, get: function () { return utils_1.MenuManager; } }); | ||
Object.defineProperty(exports, "PermissionChecker", { enumerable: true, get: function () { return utils_1.PermissionChecker; } }); | ||
exports.default = { Starter: utils_1.Starter, ButtonManager: utils_1.ButtonManager, MenuManager: utils_1.MenuManager, PermissionChecker: utils_1.PermissionChecker }; | ||
//# sourceMappingURL=index.js.map |
@@ -5,8 +5,6 @@ import { ButtonManager } from './components/Buttons'; | ||
const Components = { | ||
export { | ||
ButtonManager, | ||
MenuManager, | ||
PermissionChecker | ||
}; | ||
export { Components } | ||
}; |
import { Collection } from 'discord.js'; | ||
import { promises as fsPromises } from 'fs'; | ||
import { join } from 'path'; | ||
import { join, resolve } from 'path'; | ||
import { Command } from '../types/utils'; | ||
@@ -10,17 +10,22 @@ | ||
export async function readCommands(client: any, folderPath: string): Promise<number> { | ||
export async function readCommands(client: any, prefix: { baseDir: any; path: string }): Promise<number> { | ||
let prefixCommandCount = 0; | ||
try { | ||
await fsPromises.access(folderPath); | ||
const files = await fsPromises.readdir(folderPath, { withFileTypes: true }); | ||
const resolvedPath = resolve(prefix.baseDir, prefix.path); | ||
console.log(`Processing directory: ${resolvedPath}`); | ||
await fsPromises.access(resolvedPath); | ||
const files = await fsPromises.readdir(resolvedPath, { withFileTypes: true }); | ||
for (const file of files) { | ||
const filePath = join(folderPath, file.name); | ||
const filePath = join(resolvedPath, file.name); | ||
console.log(`Reading file: ${filePath}`); | ||
if (file.isDirectory()) { | ||
prefixCommandCount += await readCommands(client, filePath); | ||
prefixCommandCount += await readCommands(client, { baseDir: prefix.baseDir, path: filePath }); | ||
} else if (file.isFile()) { | ||
try { | ||
const command: Command = await import(filePath); | ||
const commandModule = await import(filePath); | ||
const command: Command = commandModule.default || commandModule; | ||
if (command && (command.execute || command.run)) { | ||
@@ -37,11 +42,16 @@ commands.set(command.name, command); | ||
command.description = command.description || "No description provided."; | ||
command.cooldown = command.cooldown || 1; | ||
command.usage = command.usage || "No usage information provided."; | ||
command.category = command.category || "Not categorized."; | ||
command.owner = command.owner || false; | ||
const defaultCommand: Command = { | ||
description: "No description provided.", | ||
cooldown: 1000, | ||
usage: "No usage information provided.", | ||
category: "Not categorized.", | ||
owner: false, | ||
...command | ||
}; | ||
if (command.prefix) { | ||
if (defaultCommand.prefix) { | ||
prefixCommandCount++; | ||
} | ||
console.log(`Command '${command.name}' registered.`); | ||
} else { | ||
@@ -57,6 +67,7 @@ console.warn(`Ignoring invalid command file: ${filePath}`); | ||
client.prefixSize = prefixCommandCount; | ||
console.log(`Total commands registered from directory ${resolvedPath}: ${client.prefixSize}`); | ||
return prefixCommandCount; | ||
} catch (error) { | ||
console.error(`Error reading directory: ${folderPath}`); | ||
console.error(`Error reading directory: ${prefix.path}`); | ||
console.error(error); | ||
@@ -63,0 +74,0 @@ return 0; |
@@ -7,2 +7,3 @@ import { StarterOptions, StarterInterface } from '../types/utils'; | ||
import { login } from './login'; | ||
import { readCommands } from './prefix-register'; | ||
@@ -22,2 +23,3 @@ export class Starter implements StarterInterface { | ||
if (options.prefix) { | ||
await readCommands(djs, options.prefix) | ||
await loadPrefix(djs, options.prefix); | ||
@@ -24,0 +26,0 @@ } |
import { Starter } from "./events-handler/starter"; | ||
import { Components } from './builder/utils'; | ||
import { ButtonManager, MenuManager, PermissionChecker } from './builder/utils'; | ||
export { Starter, Components } | ||
export { Starter, ButtonManager, MenuManager, PermissionChecker } |
@@ -32,5 +32,5 @@ import axios from "axios"; | ||
import { Starter, Components } from "./discord/utils"; | ||
import { Starter, ButtonManager, MenuManager, PermissionChecker } from "./discord/utils"; | ||
export { Starter, Components }; | ||
export default { Starter, Components }; | ||
export { Starter, ButtonManager, MenuManager, PermissionChecker }; | ||
export default { Starter, ButtonManager, MenuManager, PermissionChecker }; |
{ | ||
"name": "djs-builder", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Discord.js bot builder. Supports Ts and Js.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
246683
2881