discord_helper

1.0.70 • Public • Published

discord_helper

Discord_helper is a package developed to help you make a discord bot.

Installation

Go to your project folder and install it via npm

npm install discord_helper

Usage

const discord = require("discord.js"),
      client = new discord.Client(),
      discordjs_helper = require("discord_helper"),
      helper = new discordjs_helper(client);
 
 
helper.setPrefix("yourDesiredCommandPrefix");
helper.registerCommand(["some","command","triggers"],function(message,args) {
    // Something that happens when the command got run
})
client.login("YourSuperSecretDiscordToken");

Documentation

For this all to work, you have to create a new instance of the helper. To do this, do the following

const helper = new discordjs_helper(discordClient);

Now that you have your helper object, you can do the following things with it

registerCommand

Registers an command.

Arguments

  • triggers (Type: String[]): The triggers that should run the specified command
  • onExecute (Type: Function): The function that runs when the command is ran. Provided arguments: message (The message the command was ran in) and args (an array of strings representing the arguments given).

Example

helper.registerCommand(["an","example"],function(message,args) {
    message.reply("Hello!")
    console.log(message.author.tag + " ran the example command!");
})

This will reply to everyone running (prefix)an or (prefix)example with Hello! and log (MessageAuthor#1234) ran the example command! to the console.

setPrefix

Sets the prefix for the command handler.

Arguments

  • newPrefix (Type: String): The new prefix to set the prefix to

Example

helper.setPrefix("->")

This will set the prefix for commands to ->.

setCommands

THIS COMMAND HAS THE ABILITY TO BREAK YOUR BOT! PLEASE BE CAREFUL

With this function, you can override the entire commands object into what you want. Useful for registering many commands at once.

Arguments

  • newCommands (Type: JSON[]): The commands you want to set.
  • force (Type: Boolean): Are you sure?

Example

helper.setCommands({[triggers:["hi","hello"],run(message,args){message.reply("hello!")}],true);

This will set the entire commands list to just this. The only command will be "hi" or "hello", which responds with "hello!" when ran.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

(Note: Github project isnt set up yet, there is no way to contribute yet)

License

MIT

Package Sidebar

Install

npm i discord_helper

Weekly Downloads

0

Version

1.0.70

License

ISC

Unpacked Size

7.84 kB

Total Files

3

Last publish

Collaborators

  • skipper-dev