New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ic4d

Package Overview
Dependencies
Maintainers
0
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ic4d - npm Package Compare versions

Comparing version 3.0.0-beta.0 to 3.0.0-beta.1

46

dist/handler/commandHandler.js

@@ -33,3 +33,3 @@ "use strict";

constructor(client, path, runFlags, loaderOptions, handlerFlags) {
super(client);
super(client, handlerFlags === null || handlerFlags === void 0 ? void 0 : handlerFlags.debugger, handlerFlags.logToFile);
this.options = {

@@ -54,3 +54,12 @@ loadedNoChanges: "NAME was loaded. No changes were made.",

refreshApplicationCommands: false,
logToFile: false,
};
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) ||
this.flags.refreshApplicationCommands,
};
this.commandPath = path;

@@ -71,9 +80,2 @@ this.options = {

};
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,
refreshApplicationCommands: (handlerFlags === null || handlerFlags === void 0 ? void 0 : handlerFlags.refreshApplicationCommands) ||
this.flags.refreshApplicationCommands,
};
}

@@ -86,2 +88,4 @@ /**

async registerCommands(logNoChanges, serverId) {
if (this.flags.debugger)
this.debug.topMsg("registerCommands()");
logNoChanges = logNoChanges !== undefined ? logNoChanges : true;

@@ -97,3 +101,3 @@ try {

if (this.flags.debugger)
console.log(clc.red.underline(`${v.name}, `));
this.debug.refresh.sMsg(v.name);
applicationCommands.delete(v.id);

@@ -103,3 +107,3 @@ count++;

if (this.flags.debugger)
console.log(clc.red.underline("have been deleted."));
this.debug.refresh.lMsg();
console.log(clc.yellow.underline.italic(`${count} application commands (Slash Only) have been deleted.`));

@@ -182,3 +186,3 @@ }

if (this.flags.debugger)
console.debug(clc.underline.blue("\nhandleCommands() has been called and has started executing.\n"));
this.debug.topMsg("handleCommands()");
this.client.on("interactionCreate", async (interaction) => {

@@ -189,3 +193,3 @@ var _a, _b;

if (this.flags.debugger)
console.debug(clc.underline("'" + interaction.commandName + "' has been called."));
this.debug.common("'" + interaction.commandName + "' has been called.");
const localCommands = this.getLocalCommands(this.commandPath);

@@ -199,5 +203,5 @@ const commandObject = localCommands.find((cmd) => cmd.name === interaction.commandName);

if (this.flags.debugger)
console.debug(clc.bold.blue("\tUser tried running " +
this.debug.commonBlue("\tUser tried running " +
interaction.commandName +
" which is a dev command."));
" which is a dev command.");
interaction.reply({

@@ -216,4 +220,4 @@ content: this.runFlags.onlyDev,

if (this.flags.debugger)
console.debug(clc.bold.blue("\tUser did not have enough permissions to run " +
interaction.commandName));
this.debug.commonBlue("\tUser did not have enough permissions to run " +
interaction.commandName);
interaction.reply({

@@ -233,4 +237,4 @@ content: this.runFlags.userNoPerms,

if (this.flags.debugger)
console.debug(clc.bold.blue("\tBot did not have the required permissions to run " +
interaction.commandName));
this.debug.commonBlue("\tBot did not have the required permissions to run " +
interaction.commandName);
interaction.reply({

@@ -245,3 +249,3 @@ content: this.runFlags.botNoPerms,

if (this.flags.debugger)
console.debug(clc.underline("\tMiddlewares Called:"));
this.debug.common("\tMiddlewares Called:");
for (const fn of middleWare) {

@@ -253,3 +257,3 @@ let result = await fn(commandObject, interaction);

const labeled = arr[0] == "function" ? true : false;
console.debug("\t\t" +
this.debug.common("\t\t" +
clc.bold.italic.red("fn") +

@@ -264,3 +268,3 @@ " " +

if (this.flags.debugger)
console.debug(clc.bold.blue("Middlewares called, Callback to be called."));
this.debug.common("Middlewares called, Callback to be called.");
await commandObject.callback(this.client, interaction);

@@ -267,0 +271,0 @@ if (commandObject.interactions.button &&

import { Client, ApplicationCommandManager, GuildApplicationCommandManager, ApplicationCommand } from "discord.js";
import { CommandObject, ContextMenuObject, InteractionObject } from "./interfaces";
import { Interactions } from "./builders/builders";
import bare = require("cli-color/bare");
export declare function extractAllInteractions(interactionsObject: Interactions, filePath: string): InteractionObject[];
export declare class CoreHandler {
client: Client;
constructor(client: Client);
coreFlags: {
debugger: boolean;
logToFile: string | false;
};
protected currentDate(): string;
/**
* Either Logs to the console or writes to a file. If to the console, clc coloruing will be used.
* @param x String to log or write
* @param clc clc colouring.
* @param stdout Print via procress.stdout
*/
protected logOrWrite(x: string, col?: bare.Format, stdout?: boolean): void;
/**
* Object of debuger helper function which take in a string and use clc to colour it and ouput whatever debug message to the console.
* Only used by the InteractionHandler and CommandHandler, That's why it's protected, the user doesn't need this.
*/
protected debug: {
/**
* Custom string that already has clc colouring.
* @param x String to log to the console.
*/
custom: (x: string) => void;
/**
* Common Text.
* @param x String tot log to the console.
*/
common: (x: string) => void;
/**
* Common Blue Text
*/
commonBlue: (x: string) => void;
/**
* Top Level Message for the debugger. Used to tell the user which function has started running
* @param x String to log to the console.
*/
topMsg: (x: string) => void;
/**
* Used when the CommandHandler and InteravctionHander refresh the applicat5ion command.
* Commands use stdout instead of console.log cuz new line
*/
refresh: {
/**
* An item in a list of multiple items that have been deleted. Used by the ComandHandler and InteractionHandler when refreshing application commands.
* @param x String to log to the console
*/
sMsg: (x: string) => void;
/**
* Final Message to log to the console. (Logs the string "have been deleted.")
*/
lMsg: () => void;
};
};
constructor(client: Client, debugMode?: boolean, logToFile?: string | false);
protected getInteractions(path: string, getContextMenusOnly?: boolean): (ContextMenuObject | InteractionObject)[] | ContextMenuObject[];

@@ -9,0 +62,0 @@ protected getLocalCommands(path: string, exceptions?: string[]): CommandObject[];

@@ -8,2 +8,4 @@ "use strict";

const builders_1 = require("./builders/builders");
const clc = require("cli-color");
const fs_1 = require("fs");
function change(cI) {

@@ -37,4 +39,103 @@ return {

class CoreHandler {
constructor(client) {
currentDate() {
const date = new Date(Date.now());
const arr = [
"[ ",
date.getHours(),
":",
date.getMinutes(),
":",
date.getSeconds(),
" ",
date.getDate(),
"-",
date.getMonth() + 1,
"-",
date.getFullYear(),
" ]",
];
return arr.join("");
}
/**
* Either Logs to the console or writes to a file. If to the console, clc coloruing will be used.
* @param x String to log or write
* @param clc clc colouring.
* @param stdout Print via procress.stdout
*/
logOrWrite(x, col, stdout) {
if (this.coreFlags.logToFile) {
try {
// 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");
}
catch (err) {
console.log("logOrWrite() function failed to write to file!:");
console.error(err);
}
}
else {
let string = col ? col(x) : x;
stdout ? process.stdout.write(string) : console.debug(string);
}
}
constructor(client, debugMode = false, logToFile) {
this.coreFlags = {
debugger: false,
logToFile: false,
};
/**
* Object of debuger helper function which take in a string and use clc to colour it and ouput whatever debug message to the console.
* Only used by the InteractionHandler and CommandHandler, That's why it's protected, the user doesn't need this.
*/
this.debug = {
/**
* Custom string that already has clc colouring.
* @param x String to log to the console.
*/
custom: (x) => {
this.logOrWrite(x); // this is red and red has any type???
},
/**
* Common Text.
* @param x String tot log to the console.
*/
common: (x) => {
this.logOrWrite(x, clc.underline);
},
/**
* Common Blue Text
*/
commonBlue: (x) => {
this.logOrWrite(x, clc.blue.bold);
},
/**
* Top Level Message for the debugger. Used to tell the user which function has started running
* @param x String to log to the console.
*/
topMsg: (x) => {
this.logOrWrite("\n" + x + " has been called and has started executing.\n", clc.underline.blue);
},
/**
* Used when the CommandHandler and InteravctionHander refresh the applicat5ion command.
* Commands use stdout instead of console.log cuz new line
*/
refresh: {
/**
* An item in a list of multiple items that have been deleted. Used by the ComandHandler and InteractionHandler when refreshing application commands.
* @param x String to log to the console
*/
sMsg: (x) => {
this.logOrWrite(x + ", ", clc.red.underline);
},
/**
* Final Message to log to the console. (Logs the string "have been deleted.")
*/
lMsg: () => {
this.logOrWrite("have been deleted.", clc.red.underline);
},
},
};
this.client = client;
this.coreFlags.debugger = debugMode || false;
this.coreFlags.logToFile = logToFile || false;
}

@@ -41,0 +142,0 @@ getInteractions(path, getContextMenusOnly = false) {

@@ -20,3 +20,3 @@ "use strict";

constructor(client, path, loaderOptions, flags) {
super(client);
super(client, flags.debugger, flags.logToFile);
this.options = {

@@ -47,2 +47,3 @@ loadedNoChanges: "NAME was loaded. No changes were made.",

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,

@@ -109,3 +110,3 @@ };

if (this.flags.debugger)
console.debug(clc.underline.blue("\nbuttons() has been called and has started executing.\n"));
this.debug.topMsg("buttons()");
authorOnlyMsg =

@@ -151,3 +152,3 @@ authorOnlyMsg !== undefined

if (this.flags.debugger)
console.debug(clc.underline.blue("\nselectMenus() has been called and has started executing.\n"));
this.debug.topMsg("selectMenus()");
authorOnlyMsg =

@@ -193,3 +194,3 @@ authorOnlyMsg !== undefined

if (this.flags.debugger)
console.debug(clc.underline.blue("\ncontextMenus() has been called and has started executing.\n"));
this.debug.topMsg("contextMenus()");
this.client.on("interactionCreate", (interaction) => {

@@ -222,3 +223,3 @@ if (!interaction.isContextMenuCommand())

if (this.flags.debugger)
console.debug(clc.underline.blue("\nmodals() has been called and has started executing.\n"));
this.debug.topMsg("modals()");
this.client.on("interactionCreate", (interaction) => {

@@ -225,0 +226,0 @@ if (!interaction.isModalSubmit())

@@ -92,2 +92,6 @@ 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.
*/
logToFile?: string | false;
/**
* Disabling Logging of the Command Loader. Not advised but hey it's your bot. Default is false.

@@ -115,2 +119,6 @@ */

/**
* When debugger mode is enabled, Either log to console or a file.
*/
logToFile?: string | false;
/**
* Disabling Logging of the Context Menu Loader. Not advised but hey it's your bot. Default is false.

@@ -117,0 +125,0 @@ */

{
"name": "ic4d",
"version": "3.0.0-beta.0",
"version": "3.0.0-beta.1",
"description": "Discord.js Interaction and Command handler 4 Dummies",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -817,2 +817,10 @@ # ic4d

### **_logToFile: string | false_**
```
Default value: false
```
When debugger mode is enabled, Either log to console or a file.
## Example Use

@@ -858,2 +866,10 @@

### **_logToFile: string | false_**
```
Default value: false
```
When debugger mode is enabled, Either log to console or a file.
# LoaderOptions

@@ -860,0 +876,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc