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

ic4d

Package Overview
Dependencies
Maintainers
1
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 1.3.0-alpha.4 to 1.3.0-alpha.5

60

dist/handler/builders.d.ts

@@ -37,6 +37,10 @@ import { Interaction, Client, ButtonInteraction, AnySelectMenuInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, ModalSubmitInteraction, PermissionFlags } from "discord.js";

/**
* Refrenced command
* Time out (Select menu and Button) after given MILLISECONDS
*/
command: SlashCommandObject;
timeout?: number;
/**
* Message to display when interaction times out.
*/
timeoutMsg?: string;
/**
* Build the actual interaction

@@ -46,13 +50,33 @@ * @param intObject Interaction Object (see github) with properties

constructor(intObject: {
/**
* Type of interaction. Either "selectMenu", "modal" or "button"
*/
type: InteractionType;
/**
* The interaction's custom identifier
*/
customId: string;
/**
* Function run when this interaction is called.
* @param interaction Interaction. (Interacton given by the "InteractionCreate" event listener.)
* @param client Client
*/
callback: (interaction: DjsInteractionTypes, client?: Client) => void;
/**
* Set the only author status of the button. (The correct property is onlyAuthor, but this is for yall who also accidenatally type this)
*/
authorOnly?: boolean;
/**
* Set the only author status of the button.
*/
onlyAuthor?: boolean;
/**
* Time out (Select menu and Button) after given MILLISECONDS
*/
timeout?: number;
/**
* Message to display when interaction times out.
*/
timeoutMsg?: string;
});
/**
* Refrences the command object with it's properties. (Bassically shares variables with it)
* @param command Command to make a refrence to.
*/
referenceCommand(command: SlashCommandObject): void;
}

@@ -106,12 +130,32 @@ export type Interactions = {

constructor(commandObject: {
/**
* The name of the command
*/
name: string;
/**
* The description of the command
*/
description: string;
/**
* Function run when this command is called
*/
callback: (client: Client, interaction: Interaction) => void;
/**
* An array of options
*/
options?: Option[];
/**
* Permission required by the user to proceed with the command
*/
permissionsRequired?: PermissionFlags[];
/**
* Permission required by the bot to proceed with the command
*/
botPermissions?: PermissionFlags[];
/**
* Whether the command is deleted or not
*/
deleted?: boolean;
initFunc?: (t: SlashCommandObject) => void;
}, ...interaction: CommandInteractionObject[]);
}
export {};

12

dist/handler/builders.js

@@ -29,10 +29,8 @@ "use strict";

: false;
this.timeout = intObject.timeout !== undefined ? intObject.timeout : 0;
this.timeoutMsg =
intObject.timeoutMsg !== undefined
? intObject.timeoutMsg
: "Interaction timed out. You didn't click in time!";
}
/**
* Refrences the command object with it's properties. (Bassically shares variables with it)
* @param command Command to make a refrence to.
*/
referenceCommand(command) {
this.command = command;
}
}

@@ -39,0 +37,0 @@ exports.CommandInteractionObject = CommandInteractionObject;

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

onlyAuthor: cI.onlyAuthor,
timeout: cI.timeout,
timeoutMsg: cI.timeoutMsg,
};

@@ -35,3 +37,3 @@ return a;

for (const objKey of keys) {
const current = objects[objKey];
let current = objects[objKey];
current.filePath = filePath;

@@ -38,0 +40,0 @@ allInteractions.push(change(current));

@@ -10,2 +10,4 @@ import { CoreHandler } from "./coreHandler";

type: string;
timeout?: number;
timeoutMsg?: string;
callback: (interaction: ButtonInteraction | AnySelectMenuInteraction | UserContextMenuCommandInteraction | MessageContextMenuCommandInteraction | ModalSubmitInteraction, client?: Client) => void;

@@ -12,0 +14,0 @@ }

@@ -7,2 +7,5 @@ "use strict";

const errs = require("./Errors");
const Default = {
timeout: "Interaction timed out. You didn't click in time!",
};
/**

@@ -51,2 +54,4 @@ * @class

type: obj.type,
timeout: obj.timeout,
timeoutMsg: obj.timeoutMsg,
};

@@ -63,2 +68,4 @@ return acc;

type: obj.type,
timeout: obj.timeout,
timeoutMsg: obj.timeoutMsg,
};

@@ -115,2 +122,15 @@ return acc;

}
if (buttonObj.timeout !== 0 &&
buttonObj.timeout !== undefined) {
const created = new Date(interaction.message.createdTimestamp + buttonObj.timeout);
if (created < new Date()) {
interaction.update({
content: buttonObj.timeoutMsg !== undefined
? buttonObj.timeoutMsg
: Default.timeout,
components: [],
});
return;
}
}
buttonObj.callback(interaction, this.client);

@@ -151,2 +171,15 @@ }

}
if (selectObj.timeout !== 0 &&
selectObj.timeout !== undefined) {
const created = new Date(interaction.message.createdTimestamp + selectObj.timeout);
if (created < new Date()) {
interaction.update({
content: selectObj.timeoutMsg !== undefined
? selectObj.timeoutMsg
: Default.timeout,
components: [],
});
return;
}
}
selectObj.callback(interaction, this.client);

@@ -153,0 +186,0 @@ }

{
"name": "ic4d",
"version": "1.3.0-alpha.4",
"version": "1.3.0-alpha.5",
"description": "Discord.js Interaction and Command handler 4 Dummies",

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

@@ -14,8 +14,12 @@ # ic4d

- [Quick Example](#quick-example)
- [ReadyHandler](#readyhandler)
- [CommandHandler](#commandhandler)
- [InteractionHandler](#interactionhandler)
- [Command Object](#command-object)
- [Interaction Object](#interaction-object)
- Handlers
- - [ReadyHandler](#readyhandler)
- - [CommandHandler](#commandhandler)
- - [InteractionHandler](#interactionhandler)
- Objects
- - [Command Object](#command-object)
- - [Interaction Object](#interaction-object)
- [Same file Command and Interactions](#command-and-interactions-in-the-same-file)
- - [CommandInteractionObject](#commandinteractionobject)
- - [SlashCommandObject](#slashcommandobject)
- [Credit](#credits)

@@ -478,3 +482,3 @@ - [Links](#links)

module.exports = {
customId: "selectMenu",
customId: "coolSelectMenu",
type: "selectMenu",

@@ -494,3 +498,3 @@ authorOnly: true,

module.exports = {
customId: "button1",
customId: "myEpicModal",
type: "modal",

@@ -503,2 +507,18 @@ callback: (i, client) => {

## Timeout parameter
This parameter makes it so that after (foo) milliseconds, the action row will be cleared and the original message will be edited to (bar). Effectively making a button click or select menu selection have a limited time window. **(Only for **Buttons** and **Select Menus**)**
```js
module.exports = {
customId: "button5",
type: "button",
timeout: 10_000,
timeoutMsg: "You're too slow!!",
callback: (i) => {
// callback
},
};
```
## Context Menu

@@ -512,3 +532,3 @@

module.exports = {
name: "modla",
name: "context",
isCommand: false,

@@ -555,3 +575,4 @@ type: ApplicationCommandType.User,

authorOnly: true,
timeout: 20_000, // 20 seconds
timeoutMsg: "You're too slow!",
callback: async (i) => {

@@ -601,2 +622,3 @@ i.update({ content: "this is from the same file", components: [] });

type: "selectMenu", // the type of interaction. can be "selectMenu", "button" or "modal"
timeout: 10_000,
callback: (i) => {

@@ -611,22 +633,2 @@ // do something

### Methods
#### `referenceCommand`
Refrences the command object with it's properties. (Bassically shares variables with it)
- `command` - Command to make a refrence to (Type of [SlashCommandObject](#slashcommandobject))
```js
const cmd = new SlashCommandObject(/* ... */, mySelect)
mySelect.referenceCommand(cmd)
```
and to call any properties in the command, call:
```js
mySelect.cmd; // the command's name
```
## SlashCommandObject

@@ -633,0 +635,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