# @demostanis.worlds/discord.js-commander

> Make your Discord bot commands look like Bash commands`

Latest version **1.0.1** (published 2019-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @demostanis.worlds/discord.js-commander
pnpm add @demostanis.worlds/discord.js-commander
yarn add @demostanis.worlds/discord.js-commander
bun add @demostanis.worlds/discord.js-commander
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-08-19 |
| First published | 2019-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | demostanis |
| Maintainers | demostanis.worlds |
| Keywords | discord.js-commander, discord-commander, discord.js, discord, commander |

## Links

- npm: https://www.npmjs.com/package/@demostanis.worlds/discord.js-commander
- Repository: https://github.com/demostanis-worlds/discord.js-commander
- Homepage: https://github.com/demostanis-worlds/discord.js-commander#readme
- Issues: https://github.com/demostanis-worlds/discord.js-commander/issues
- npm.io page: https://npm.io/package/@demostanis.worlds/discord.js-commander

## Dependencies (6)

- [@babel/cli](https://npm.io/package/@babel/cli.md) ^7.5.5
- [discord.js](https://npm.io/package/discord.js.md) ^11.5.1
- [tiny-timer](https://npm.io/package/tiny-timer.md) ^1.4.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.5.5
- [parse-command](https://npm.io/package/parse-command.md) 0.0.102
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.5.5

## Recent versions

- 1.0.1 (latest) — 2019-08-19
- 1.0.0 — 2019-08-19

## README

# Discord.js commander
# Make your Discord bot commands look like Bash commands

# Install
```sh
npm install @demostanis.worlds/discord.js-commander
```

# Example
```js
import Discord from "discord.js"
import DiscordCommander from "@demostanis.worlds/discord.js-commander"
import "dotenv/config"

const client = new Discord.Client()

client.on("ready", () => {
	console.log(`Logged in as ${client.user.tag}`)

	const commander = new DiscordCommander({
		client: client,
		commands: [{
			name: "*order-pizza",
			description: "Orders a pizza.",
			timeout: 10000,
			argumentList: [{
				name: "<type>",
				description: "Type of the pizza to order.",
				required: true
			}, {
				name: "<size>",
				description: "Size of the pizza to order.",
				required: false
			}],
			optionList: [{
				name: "--bacon",
				description: "Adds bacon to the pizza."
			}, {
				name: "--cheese",
				description: "Adds cheese to the pizza.",
				vipOnly: true
			}],
			does(message, argumentList, optionList) {
				const type = argumentList.get("<type>")
				const size = argumentList.get("<size>")
				const bacon = optionList.get("--bacon")
				const cheese = optionList.get("--cheese")

				message.channel.send(`Ordering pizza ${type} and size ${size ? size : "normal"} ${bacon ? "with bacon" : "without bacon"} ${cheese ? "and cheese": "and without cheese"}`)
			}
		}],
		argumentRequiredMessage: arg => `you forgot required argument: ${arg.name}.`,
		commandInTimeoutMessage: timeLeft => `please slow down! ${timeLeft}ms left.`,
		vipOnlyCommandMessage: command => `${command.name} command is reserved for VIPs. Become VIP at https://patreon.com/demostanis.`,
		vipOnlyOptionMessage: option => `${option.name} option is reserved for VIPs. Become VIP at https://patreon.com/demostanis.`,
		disabledChannels: client.channels.filter(channel => !(["601766574206222347", "604250599927578624"].indexOf(channel.id) >= 0)),
		vipRole: "604250294846750720"
	})
})

client.login(process.env.TOKEN)
```

# API
- new DiscordCommander(options: Options) => DiscordCommander

```ts
export as namespace DiscordCommander

export interface Options {
	client: Discord.Client
	commands: Commands[]
	argumentRequiredMessage: Function
	commandInTimeoutMessage: Function
	vipOnlyCommandMessage: Function
	vipOnlyOptionMessage: Function
	disabledChannels: Discord.Collection
	vipRole: string
}

export interface Commands {
	name: string
	description: string
	timeout: number
	argumentList: Argument[]
	optionList: Option[]
	does: Function
}

export interface Argument {
	name: string
	description: string
	required: boolean
}

export interface Option {
	name: string
	descriptiob: string
	vipOnly: boolean
}
```

---
_Source: https://npm.io/package/@demostanis.worlds/discord.js-commander · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
