
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
discord-handles
Advanced tools
For those of us who get frustrated with writing command handlers but don't quite want to use a full framework. Intended for use with Discord.js.
Documentation is available at handles.topkek.pw.
npm install --save discord-handles
Or, if you want to risk cutting yourself, install the bleeding edge version:
npm install --save appellation/handles#master
Usually I try to avoid pushing broken code, but sometimes I move a little too fast.
const discord = require('discord.js');
const handles = require('discord-handles');
const client = new discord.Client();
const handler = new handles.Client(client);
client.login('token');
This will automatically load all commands in the ./commands
directory and handle incoming messages. See Command
in the docs for information on how to format the exports of the files you place in ./commands
. Particularly of interest are the pre
, exec
, and post
methods. The loader and handler can be configured according to Config
options passed to the constructor.
const handler = new handles.Client(client, {
directory: './some/other/awesome/directory',
prefixes: new Set(['dank', 'memes'])
});
Here's an example of what you might place in the ./commands
directory.
const { MessageMentions, Permissions } = require('discord.js');
const { Command, Argument, Validator } = require('discord-handles');
module.exports = class extends Command {
static get triggers() {
return ['banne', 'ban'];
}
async pre() {
await this.guild.fetchMembers();
await new Validator(this)
.apply(this.guild.me.permissions.has(Permissions.FLAGS.BAN_MEMBERS), 'I don\'t have permission to ban people.')
.apply(this.member.permissions.has(Permissions.FLAGS.BAN_MEMBERS), 'You don\'t have permission to ban people.');
const member = await new Argument(this, 'member')
.setResolver(c => {
const member = this.guild.members.get(c);
// if they provided a raw user ID
if (member) return member;
// if they mentioned someone
else if (MessageMentions.USERS_PATTERN.test(c)) return this.guild.members.get(c.match(MessageMentions.USERS_PATTERN)[1]);
// if they provided a user tag
else if (this.guild.members.exists(u => u.tag === c)) return this.guild.members.find(u => u.tag === c);
else return null;
})
.setPrompt('Who would you like to ban?')
.setRePrompt('You provided an invalid user. Please try again.');
await new Validator(this)
.apply(member.bannable, 'I cannot ban this person.');
.apply(member.highestRole.position < this.member.highestRole.position, 'You cannot ban this person.')
await new Argument(this, 'days')
.setResolver(c => parseInt(c) || null);
.setOptional();
}
async exec() {
await this.args.member.ban(this.args.days);
return this.response.success(`banned ${this.args.member.user.tag}`);
}
};
FAQs
A simple Discord command handler.
The npm package discord-handles receives a total of 2 weekly downloads. As such, discord-handles popularity was classified as not popular.
We found that discord-handles 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.