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

discord-message-handler

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-message-handler - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

package.json
{
"name": "discord-message-handler",
"version": "1.0.3",
"version": "1.0.4",
"description": "Message and command handler for discord.js bots and applications.",

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

@@ -1,8 +0,8 @@

##About
## About
**discord-message-handler** is a module written to simplify message and command handling for [discord.js](https://github.com/hydrabolt/discord.js) bots and applications.
##Installation
## Installation
Simply navigate to your project's folder and type `npm install discord-message-handler --save` on the command line.
##Usage
## Usage
To start using the module you must require it into you script like this:

@@ -19,3 +19,3 @@ ```js

###Simple message handlers
### Simple message handlers
```js

@@ -29,3 +29,3 @@ MessageHandler.whenMessageContainsWord("shrug").reply("¯\\_(ツ)_/¯");

###Command handler
### Command handler
```js

@@ -37,4 +37,11 @@ MessageHandler.onCommand("/doit").do((args, rawArgs, message) => {

###Commands with usage info
### Commands with alias
```js
MessageHandler.onCommand("/information").alias("/info").alias("/i").do((args) => {
doSomething(args[0]);
});
```
### Commands with usage info
```js
MessageHandler

@@ -50,3 +57,3 @@ .onCommand("/info")

###Case sensitivity
### Case sensitivity
In case you want message filters to be case sensitive you just need to call this function once:

@@ -58,3 +65,3 @@ ```js

###Logging
### Logging
To enable logging call `MessageHandler.enableLogging()` and pass a function to handle logs.

@@ -67,3 +74,3 @@ ```js

##Contributing
## Contributing
Feel free to send a pull request or open an issue if something is not working as intended or you belive could be better.

@@ -33,2 +33,7 @@ const MessageType = {

static startsWithWord(str, search) {
return ((str.length == search.length) && (str == search)) ||
((str.length > search.length) && (str.startsWith(search + ' ')))
}
static getKeyByValue(obj, value) {

@@ -89,2 +94,11 @@ for (var prop in obj) {

alias(alt) {
if (this.handler.aliases) {
this.handler.aliases.push(alt);
} else {
this.handler.aliases = [alt];
}
return this;
}
whenInvalid(message) {

@@ -241,3 +255,9 @@ this.handler.errorMessage = message;

case MessageType.COMMAND:
return message.startsWith(query);
if (handler.aliases) {
handler.aliases.push(query);
let check = handler.aliases.map(q => Utils.startsWithWord(message, q));
return check.reduce((a, b) => a || b);
} else {
return Utils.startsWithWord(message, query);
}
case MessageType.MESSAGE_ENDS_WITH:

@@ -244,0 +264,0 @@ return message.endsWith(query);

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