1.4.6 • Published 5 years ago

discordutil v1.4.6

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

discordutil

Discord NPM Version NPM Dependencies NPM Downloads GitHub Stars License

Powerful set of utilities for Discord.js. New to discordutil? Check out the API Reference.

Installation

npm install discordutil

Usage

Importing the package

const DiscordUtil = require('discordutil');
const Discord = require('discord.js'); // optional

CommandHandler

const bot = new Discord.Client();
const handler = new DiscordUtil.CommandHandler({
  client: bot,
  commandDir: __dirname + '/commands',
  prefix: '!'
}).load();

// commands/ping.js
module.exports = {
  name: 'ping',
  aliases: ['pong'],
  run(client, message, args) {
    return message.reply('Pong!');
  }
}

EventHandler

const bot = new Discord.Client();
const handler = new DiscordUtil.EventHandler({
  client: bot,
  eventDir: __dirname + '/events'
}).load();

// events/ready.js
module.exports = client => {
  console.log(`Logged in as ${client.user.tag}!`);
}

Swear Detector

// Message event
const words = ['swear', 'words', 'here'];
if (DiscordUtil.isSwear(message.content, words)) {
  return message.reply('No swearing!');
}

Extra Utilities

DiscordUtil
  .formatDate(new Date()); // 10/8/2019
  .msToReadable(8.64e+7); // 24:00:00
  .parseMs(8.64e+7); // { days: 1, hours: 0, minutes: 0, seconds: 0, ... }
  .randomColor(); // #b35c44
  .randomNumber(10, 100); // 67
  .deconstructSnowflake(220954374770262017); // { timestamp: 1472750028079, ... }
1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago