Comparing version 3.0.0 to 4.0.0-beta.0
@@ -33,3 +33,3 @@ "use strict"; | ||
constructor(client, path, runFlags, loaderOptions, handlerFlags) { | ||
super(client, handlerFlags === null || handlerFlags === void 0 ? void 0 : handlerFlags.debugger, handlerFlags.logToFile); | ||
super("cHandler", client, handlerFlags?.debugger, handlerFlags.logToFile); | ||
this.options = { | ||
@@ -57,7 +57,7 @@ loadedNoChanges: "NAME was loaded. No changes were made.", | ||
this.flags = { | ||
debugger: (handlerFlags === null || handlerFlags === void 0 ? void 0 : handlerFlags.debugger) || this.flags.debugger, | ||
disableLogs: (handlerFlags === null || handlerFlags === void 0 ? void 0 : handlerFlags.disableLogs) || this.flags.disableLogs, | ||
production: (handlerFlags === null || handlerFlags === void 0 ? void 0 : handlerFlags.production) || this.flags.production, | ||
logToFile: (handlerFlags === null || handlerFlags === void 0 ? void 0 : handlerFlags.logToFile) || this.flags.logToFile, | ||
refreshApplicationCommands: (handlerFlags === null || handlerFlags === void 0 ? void 0 : handlerFlags.refreshApplicationCommands) || | ||
debugger: handlerFlags?.debugger || this.flags.debugger, | ||
disableLogs: handlerFlags?.disableLogs || this.flags.disableLogs, | ||
production: handlerFlags?.production || this.flags.production, | ||
logToFile: handlerFlags?.logToFile || this.flags.logToFile, | ||
refreshApplicationCommands: handlerFlags?.refreshApplicationCommands || | ||
this.flags.refreshApplicationCommands, | ||
@@ -67,14 +67,14 @@ }; | ||
this.options = { | ||
loadedNoChanges: clc.magenta.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.loadedNoChanges) || this.options.loadedNoChanges), | ||
loaded: clc.green.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.loaded) || this.options.loaded), | ||
edited: clc.yellow.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.edited) || this.options.edited), | ||
deleted: clc.red.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.deleted) || this.options.deleted), | ||
skipped: clc.cyan.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.skipped) || this.options.skipped), | ||
loadedNoChanges: clc.magenta.bold(loaderOptions?.loadedNoChanges || this.options.loadedNoChanges), | ||
loaded: clc.green.bold(loaderOptions?.loaded || this.options.loaded), | ||
edited: clc.yellow.bold(loaderOptions?.edited || this.options.edited), | ||
deleted: clc.red.bold(loaderOptions?.deleted || this.options.deleted), | ||
skipped: clc.cyan.bold(loaderOptions?.skipped || this.options.skipped), | ||
}; | ||
this.runFlags = { | ||
testGuildId: (runFlags === null || runFlags === void 0 ? void 0 : runFlags.testGuildId) || undefined, | ||
devs: (runFlags === null || runFlags === void 0 ? void 0 : runFlags.devs) || [], | ||
onlyDev: (runFlags === null || runFlags === void 0 ? void 0 : runFlags.onlyDev) || this.runFlags.onlyDev, | ||
userNoPerms: (runFlags === null || runFlags === void 0 ? void 0 : runFlags.userNoPerms) || this.runFlags.userNoPerms, | ||
botNoPerms: (runFlags === null || runFlags === void 0 ? void 0 : runFlags.botNoPerms) || this.runFlags.botNoPerms, | ||
testGuildId: runFlags?.testGuildId || undefined, | ||
devs: runFlags?.devs || [], | ||
onlyDev: runFlags?.onlyDev || this.runFlags.onlyDev, | ||
userNoPerms: runFlags?.userNoPerms || this.runFlags.userNoPerms, | ||
botNoPerms: runFlags?.botNoPerms || this.runFlags.botNoPerms, | ||
}; | ||
@@ -185,3 +185,2 @@ } | ||
this.client.on("interactionCreate", async (interaction) => { | ||
var _a, _b; | ||
if (!interaction.isChatInputCommand()) | ||
@@ -209,3 +208,3 @@ return; | ||
} | ||
if ((_a = commandObject.permissionsRequired) === null || _a === void 0 ? void 0 : _a.length) { | ||
if (commandObject.permissionsRequired?.length) { | ||
for (const permission of commandObject.permissionsRequired) { | ||
@@ -226,3 +225,3 @@ if ( | ||
} | ||
if ((_b = commandObject.botPermissions) === null || _b === void 0 ? void 0 : _b.length) { | ||
if (commandObject.botPermissions?.length) { | ||
for (const permission of commandObject.botPermissions) { | ||
@@ -229,0 +228,0 @@ const bot = interaction.guild.members.me; |
@@ -6,2 +6,3 @@ import { Client, ApplicationCommandManager, GuildApplicationCommandManager, ApplicationCommand } from "discord.js"; | ||
export declare function extractAllInteractions(interactionsObject: Interactions, filePath: string): InteractionObject[]; | ||
export type Handlers = "iHandler" | "cHandler" | "rHandler"; | ||
export declare class CoreHandler { | ||
@@ -11,5 +12,6 @@ client: Client; | ||
debugger: boolean; | ||
logToFile: string | false; | ||
logToFolder: string | false; | ||
}; | ||
protected currentDate(): string; | ||
private subClassName; | ||
protected currentTime(): string; | ||
/** | ||
@@ -62,3 +64,3 @@ * Either Logs to the console or writes to a file. If to the console, clc coloruing will be used. | ||
}; | ||
constructor(client: Client, debugMode?: boolean, logToFile?: string | false); | ||
constructor(extender: Handlers, client: Client, debugMode?: boolean, logToFolder?: string | false); | ||
protected getInteractions(path: string, getContextMenusOnly?: boolean): (ContextMenuObject | InteractionObject)[] | ContextMenuObject[]; | ||
@@ -65,0 +67,0 @@ protected getLocalCommands(path: string, exceptions?: string[]): CommandObject[]; |
@@ -38,3 +38,3 @@ "use strict"; | ||
class CoreHandler { | ||
currentDate() { | ||
currentTime() { | ||
const date = new Date(Date.now()); | ||
@@ -48,8 +48,2 @@ const arr = [ | ||
date.getSeconds(), | ||
" ", | ||
date.getDate(), | ||
"-", | ||
date.getMonth() + 1, | ||
"-", | ||
date.getFullYear(), | ||
" ]", | ||
@@ -66,7 +60,13 @@ ]; | ||
logOrWrite(x, col, stdout) { | ||
if (this.coreFlags.logToFile) { | ||
if (this.coreFlags.logToFolder) { | ||
x = x.replace(/\x1b\[([0-9;]*)m/g, ""); | ||
try { | ||
const date = new Date(Date.now()); | ||
const path = path2.join(this.coreFlags.logToFolder, date.getDate() + | ||
"-" + | ||
(date.getMonth() + 1) + | ||
"-" + | ||
date.getFullYear(), "_", this.subClassName, ".log.txt"); | ||
// If `logToFile` is a valid file path, append the message with a newline | ||
(0, fs_1.appendFileSync)(this.coreFlags.logToFile, this.currentDate() + " " + x + "\n", "utf8"); | ||
(0, fs_1.appendFileSync)(path, this.currentTime() + " " + x + "\n\n", "utf8"); | ||
} | ||
@@ -83,6 +83,6 @@ catch (err) { | ||
} | ||
constructor(client, debugMode = false, logToFile) { | ||
constructor(extender, client, debugMode = false, logToFolder) { | ||
this.coreFlags = { | ||
debugger: false, | ||
logToFile: false, | ||
logToFolder: false, | ||
}; | ||
@@ -141,5 +141,6 @@ /** | ||
}; | ||
this.subClassName = extender; | ||
this.client = client; | ||
this.coreFlags.debugger = debugMode || false; | ||
this.coreFlags.logToFile = logToFile || false; | ||
this.coreFlags.logToFolder = logToFolder || false; | ||
} | ||
@@ -223,3 +224,2 @@ getInteractions(path, getContextMenusOnly = false) { | ||
areCommandsDifferent(existingCommand, localCommand) { | ||
var _a, _b, _c, _d; | ||
const areChoicesDifferent = (existingChoices = [], localChoices = []) => { | ||
@@ -234,3 +234,2 @@ return localChoices.some((localChoice) => { | ||
return localOptions.some((localOption) => { | ||
var _a, _b; | ||
const existingOption = existingOptions.find((option) => option.name === localOption.name); | ||
@@ -242,4 +241,4 @@ return (!existingOption || | ||
existingOption.required || | ||
(((_a = localOption.choices) === null || _a === void 0 ? void 0 : _a.length) || 0) !== | ||
(((_b = existingOption.choices) === null || _b === void 0 ? void 0 : _b.length) || 0) || | ||
(localOption.choices?.length || 0) !== | ||
(existingOption.choices?.length || 0) || | ||
areChoicesDifferent(localOption.choices, existingOption.choices)); | ||
@@ -249,4 +248,4 @@ }); | ||
return (existingCommand.description !== localCommand.description || | ||
(((_a = existingCommand.options) === null || _a === void 0 ? void 0 : _a.length) || 0) !== | ||
(((_b = localCommand.options) === null || _b === void 0 ? void 0 : _b.length) || 0) || | ||
(existingCommand.options?.length || 0) !== | ||
(localCommand.options?.length || 0) || | ||
areOptionsDifferent( | ||
@@ -257,4 +256,4 @@ //@ts-ignore | ||
(localCommand.data | ||
? ((_c = localCommand.data) === null || _c === void 0 ? void 0 : _c.nsfw) | ||
? (_d = localCommand.data) === null || _d === void 0 ? void 0 : _d.nsfw | ||
? localCommand.data?.nsfw | ||
? localCommand.data?.nsfw | ||
: false | ||
@@ -261,0 +260,0 @@ : false)); |
@@ -20,3 +20,3 @@ "use strict"; | ||
constructor(client, path, loaderOptions, flags) { | ||
super(client, flags.debugger, flags.logToFile); | ||
super("iHandler", client, flags.debugger, flags.logToFile); | ||
this.options = { | ||
@@ -38,13 +38,13 @@ loadedNoChanges: "NAME was loaded. No changes were made.", | ||
this.options = { | ||
loadedNoChanges: clc.magenta.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.loadedNoChanges) || this.options.loadedNoChanges), | ||
loaded: clc.green.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.loaded) || this.options.loaded), | ||
edited: clc.yellow.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.edited) || this.options.edited), | ||
deleted: clc.red.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.deleted) || this.options.deleted), | ||
skipped: clc.cyan.bold((loaderOptions === null || loaderOptions === void 0 ? void 0 : loaderOptions.skipped) || this.options.skipped), | ||
loadedNoChanges: clc.magenta.bold(loaderOptions?.loadedNoChanges || this.options.loadedNoChanges), | ||
loaded: clc.green.bold(loaderOptions?.loaded || this.options.loaded), | ||
edited: clc.yellow.bold(loaderOptions?.edited || this.options.edited), | ||
deleted: clc.red.bold(loaderOptions?.deleted || this.options.deleted), | ||
skipped: clc.cyan.bold(loaderOptions?.skipped || this.options.skipped), | ||
}; | ||
this.flags = { | ||
debugger: (flags === null || flags === void 0 ? void 0 : flags.debugger) || this.flags.debugger, | ||
disableLogs: (flags === null || flags === void 0 ? void 0 : flags.disableLogs) || this.flags.disableLogs, | ||
logToFile: (flags === null || flags === void 0 ? void 0 : flags.logToFile) || this.flags.logToFile, | ||
refreshContextMenus: (flags === null || flags === void 0 ? void 0 : flags.refreshContextMenus) || this.flags.refreshContextMenus, | ||
debugger: flags?.debugger || this.flags.debugger, | ||
disableLogs: flags?.disableLogs || this.flags.disableLogs, | ||
logToFile: flags?.logToFile || this.flags.logToFile, | ||
refreshContextMenus: flags?.refreshContextMenus || this.flags.refreshContextMenus, | ||
}; | ||
@@ -51,0 +51,0 @@ } |
@@ -93,2 +93,4 @@ import { AnySelectMenuInteraction, ApplicationCommandOptionType, ButtonInteraction, ChatInputCommandInteraction, Client, Interaction, MessageContextMenuCommandInteraction, ModalSubmitInteraction, RESTPostAPIApplicationCommandsJSONBody, UserContextMenuCommandInteraction } from "discord.js"; | ||
* When debugger mode is enabled, Either log to console or a file. | ||
* | ||
* When log to file specify a FOLDER path | ||
*/ | ||
@@ -120,2 +122,4 @@ logToFile?: string | false; | ||
* When debugger mode is enabled, Either log to console or a file. | ||
* | ||
* When log to file specify a FOLDER path | ||
*/ | ||
@@ -122,0 +126,0 @@ logToFile?: string | false; |
@@ -13,3 +13,3 @@ "use strict"; | ||
constructor(client, ...functions) { | ||
super(client); | ||
super("rHandler", client); | ||
this.emitErr = false; | ||
@@ -16,0 +16,0 @@ this.functionsToRun = []; |
{ | ||
"name": "ic4d", | ||
"version": "3.0.0", | ||
"version": "4.0.0-beta.0", | ||
"description": "Discord.js Interaction and Command handler 4 Dummies", | ||
@@ -12,3 +12,5 @@ "main": "dist/index.js", | ||
"build": "npx tsc", | ||
"deps": "npm i" | ||
"deps": "npm i", | ||
"test": "echo \"Error: no test specified\" && exit 0", | ||
"publish": "npm run build && npm publish" | ||
}, | ||
@@ -44,5 +46,5 @@ "repository": { | ||
"devDependencies": { | ||
"@types/node": "^20.14.9", | ||
"discord.js": "^14.15.3", | ||
"typescript": "^5.5.2" | ||
"@types/node": "^22.8.0", | ||
"discord.js": "^14.16.3", | ||
"typescript": "^5.6.3" | ||
}, | ||
@@ -49,0 +51,0 @@ "dependencies": { |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1872
146361
2