Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@discordia/action
Advanced tools
Note: Some of the links in this README file work better on the documentation site
# install the module using npm
npm install @discordia/action
# install the module using yarn
yarn add @discordia/action
Discordia actions are designed to be used with a Discordia framework instance. See the section on testing below for details on how to validate your actions.
const DiscordiaAction = require('@discordia/action');
const pingAction = new DiscordiaAction('ping', 'pong');
# Conversation Example(s)
User: @BotName ping
BotName: @User, pong
Every Discordia action is made of three pieces: an accessor, a response, and an optional description.
The accessor is how the Discordia framework determines whether or not this action should give its response. The Discordia framework calls the action's checkAccessor method which in turn determines whether or not to call the action's handleAction method based on the type of the accessor. The checkAccessor method is given four parameters:
Parameter | Description |
---|---|
userAction | The first string after the name of the bot that triggered the framework |
msg | The full Message object that contains userAction and userArgs in its content |
userArgs | Everything in side the msg.content field after userAction as an array |
client | The full Client object used by the Discordia framework - USE WITH CAUTION |
String
If the accessor is a string and matches userAction
exactly then handleAction for this action will be called.
Array
If the accessor is an array and any of its entries matches userAction
exactly then handleAction for this action will be called.
Function
If the accessor is a function that returns true when provided with userAction
, msg
, and client
then handleAction for this action will be called.
The response is how the Discordia framework responds to a user that tries to interact with the bot it creates. Once handleAction is called it will determine how to respond to the user based on the type of the response. The handleAction method is given three parameters:
Parameter | Description |
---|---|
msg | The full Message object that contains userAction and userArgs in its content |
userArgs | Everything in side the msg.content field after userAction as an array |
client | The full Client object used by the Discordia framework - USE WITH CAUTION |
String
If the response is a string then msg.reply is called with response as the content
parameter.
Function
If the response is a function then that function will be called with msg
, userArgs
, and client
as parameters. If the function returns a string then msg.reply is called with the result of that function as the content
parameter.
Description is an optional parameter that must be a string used to enable a help
(or h
) action on the Discordia framework. By default the discordia framework will attempt to supply usage information to server members who ask the bot created by the Discordia framework for help.
// Default Behavior
`-------------------------
**Command**: \`${accessor}\`
${description}`
Accessor is formatted based on its type to show the available options (with "{Dynamic Accessor}" sent if the accessor is a function). The description is the exact contents of the description parameter given to the Discordia action constructor.
If description is ommitted or set to null
then the whole action will be left off when the the help action is triggered.
The behavior of the help command can be overriden - see the Discordia Framework constructor.
const DiscordiaAction = require('@discordia/action');
const pingAction = new DiscordiaAction('ping', 'pong');
# Conversation Example(s)
User: @BotName ping
BotName: @User, pong
const DiscordiaAction = require('@discordia/action');
const ouchAction = new DiscordiaAction(['oof', 'ow', 'ouch'], 'rekt');
# Conversation Example(s)
User: @BotName oof
BotName: @User, rekt
---
User: @BotName ow
BotName: @User, rekt
---
User: @BotName ouch
BotName: @User, rekt
const DiscordiaAction = require('@discordia/action');
const accessor = (userAction, msg, client) => {
if (msg.content.includes('potato')) {
return true;
}
return false;
};
const potatoAction = new DiscordiaAction(accessor, 'delicious');
# Conversation Example(s)
User: @BotName Do you like potatoes?
BotName: @User, delicious
const DiscordiaAction = require('@discordia/action');
const response = (userArgs, msg, client) => {
return `here is a joke for ${msg.author.username}: ${generateJoke()}`;
};
const jokeAction = new DiscordiaAction('joke', response);
# Conversation Example(s)
User: @BotName joke
BotName: @User, here is a joke for User: {something funny}
🚧 Coming Soon! 🚧
FAQs
Class for creating discordia actions
The npm package @discordia/action receives a total of 38 weekly downloads. As such, @discordia/action popularity was classified as not popular.
We found that @discordia/action demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.