1.4.4 • Published 6 years ago

@demostanis.worlds/discord-commander v1.4.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Discord-commander

Easily make commands for your discord bot

Install

npm install --save @demostanis.worlds/discord-commander

Import

/**
 * ES6
 */

import { DiscordCommander } from "@demostanis.worlds/discord-commander"
import Discord from "discord.js"

/**
 * CommonJS
 */

const { DiscordCommander } = require("@demostanis.worlds/discord-commander")
const Discord = require("discord.js")

Usage

new DiscordCommander({
  client: Discord.Client,
  vipRole?: string|false,
  vipOnlyMessage?: string|Function,
  argumentRequiredMessage: string|Function,
  commands: Command[],
  timeoutMessage: string|Function,
  disableDMs: true|false
})

Examples

import { DiscordCommander } from "@demostanis.worlds/discord-commander"
import Discord from "discord.js"
 
const client = new Discord.Client()
 
client.on("ready", () => {
  console.log(`Logged in as ${client.user.tag}!`)
 
  const commander = new DiscordCommander({
    client: client,
    vipRole: "604250294846750720",
    vipOnlyMessage: "Sorry! This command is only available for VIPs.",
	argumentRequiredMessage: "It seems that you forgot an argument which is required...",
	timeoutMessage: "Please slow down...",
    commands: [{
      name: "*order-pizza",
	  description: "Orders pizza.",
	  timeout: 1000,
      argumentList: [{
        name: "type",
        description: "Sets the type of the pizza you're ordering.",
		required: true,
		length: 2
      }],
      optionList: [{
        name: "--cheese",
        description: "Adds some cheese to your pizza."
      }, {
        name: "--mushrooms",
        description: "Adds some mushrooms to your pizza.",
        vipOnly: true
	  }],
	  does(message, argumentList, optionList) {
		const type = argumentList.get("type")
		const cheese = optionList.get("--cheese")
		const mushrooms = optionList.get("--mushrooms")
   
		message.channel.send(`Ordering ${type} pizza with: `)
   
		if(cheese) {
		  message.channel.send("- Some cheese")
		}
   
		if(mushrooms) {
		  message.channel.send("- Some mushrooms")
		}
   
		orderPizza(type, cheese, mushrooms)

		/**
		 * *order-pizza Classic pizza --cheese --mushrooms
		 * 
		 * Ordering Classic pizza with:
		 *  - Some cheese
		 *  - Some mushrooms
		 */
	  }
	}]
  })
})
 
client.login(TOKEN)

Issues

  • For any issue, please tell them here.
1.4.4

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago