# simply-discord

> A simple and easy to use Discord bot command handler, built for Discord.js

Latest version **1.2.1** (published 2021-07-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install simply-discord
pnpm add simply-discord
yarn add simply-discord
bun add simply-discord
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2021-07-06 |
| First published | 2021-02-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 15 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Townsy#0001 |
| Maintainers | townsy |

## Links

- npm: https://www.npmjs.com/package/simply-discord
- Repository: https://github.com/Townsy45/simply-discord
- Homepage: https://github.com/Townsy45/simply-discord#readme
- Issues: https://github.com/Townsy45/simply-discord/issues
- npm.io page: https://npm.io/package/simply-discord

## Dependencies (4)

- [moment](https://npm.io/package/moment.md) ^2.29.1
- [discord.js](https://npm.io/package/discord.js.md) ^12.5.1
- [mustang-log](https://npm.io/package/mustang-log.md) ^1.1.2
- [moment-duration-format](https://npm.io/package/moment-duration-format.md) ^2.3.2

## Recent versions

- 1.2.1 (latest) — 2021-07-06
- 1.2.0 — 2021-07-04
- 1.1.8 — 2021-05-19
- 1.1.7 — 2021-03-07
- 1.1.6 — 2021-03-07
- 1.1.5 — 2021-02-24
- 1.1.4 — 2021-02-21
- 1.1.3 — 2021-02-21
- 1.1.2 — 2021-02-21
- 1.1.1 — 2021-02-21
- 1.1.0 — 2021-02-21
- 1.0.1 — 2021-02-20
- 1.0.0 — 2021-02-20

## README

[![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/not-a-bug-a-feature.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/check-it-out.svg)](https://forthebadge.com)

[![NPM](https://nodei.co/npm/simply-discord.png)](https://nodei.co/npm/simply-discord/)

# Simply Discord

A simple Discord bot command handler that is easy to use, built for Discord.js

```js
const { client } = new SimplyDiscord({
  defaultPrefix: '-',
  commandsDir: './commands',
  eventsDir: './events',
  allowDMs: false
})

.setGuildPrefix('GUILD_ID', 'NEW_PREFIX')
.setCommandsDir('NEW_DIRECTORY')
.setEventsDir('NEW_DIRECTORY')
.setDefaultPrefix('NEW_DEFAULT_PREFIX')
.toggleDMs()
.reload();
```

**Params:**

| Param | Type | Info
| ------------- | :---: | ------------- |
| client  | `Discord.Client`  | The Discord client, if not passed one will be created
| options  | `object`  | More info below

**Available Options:**

| Option | Type | Default | Info |
| ------------- | :---: | :---: | ------------- |
| options  | `object`  | `undefined` | Options to configure the handler
| options.defaultPrefix  | `string`  | `!` | Default prefix to use in-case of no guild prefix
| options.commandsDir  | `string`  | `./commands` | Folder containing all your commands
| options.eventsDir  | `string`  | `./events` | Folder containing your event files
| options.allowDMs  | `boolean`  | `true` | Bot should respond in DMs?

## Handler Functions:

```js
// Example Functions
const Handler = new SimplyDiscord();

// Set the guild prefix
Handler.setGuildPrefix('714478443099873310', '-');

// Set the dir but do not reload commands
Handler.setCommandsDir('./commands/sub', false);

// Set the events dir
// By default it will reload commands/events
Handler.setEventsDir('./events/new');

// Manually reload commands/events (Default will reload both)
Handler.reload('commands'); // Reload just commands
Handler.reload('events'); // Reload just events
Handler.reload(); // Reload both

// Toggle DMs (Specify true/false or it will flip the current state)
console.log(Handler.allowDMs) // Output -> True
Handler.toggleDMs();
console.log(Handler.allowDMs) // Output -> False

```

| Function | Params | Info |
| ------------- | :---: | ------------- |
| setCommandsDir  | `('Directory')`  | Update the folder where your commands are located |
| setDefaultPrefix  | `('Prefix')`  | Update the default prefix |
| setGuildPrefix  | `('GuildID', 'Prefix')`  | Set the guild prefix to the client.prefixes collection |
| setEventsDir  | `('Directory')`  | Update the folder where your events are located |
| toggleDMs  | `(true/false)`  | Toggle if DMs should be allowed, sending nothing with switch it |
| reload  | `('commands'/'events')`  | Reload commands/events or both |

## Usage

Using the handler:
```js
const Discord = require('discord.js');
const SimplyDiscord = require('simply-discord');
const client = new Discord.Client();

new SimplyDiscord(client, {
  commandsDir: 'lib/commands'
});
```
*Note: Simply Discord will create a client for you if you don't provide one*
```js
const SimplyDiscord = require('simply-discord');

/* Client is a property of the SimplyDiscord Class, use this to access the Discord Client */
const { client } = new SimplyDiscord({ commandsDir: 'lib/commands' });

/* Assign it to a variable and use that to access the props and functions */

const simply = new SimplyDiscord({ commandsDir: 'lib/commands' });
const client = simply.client;

/*  Minimum usage  */

const simply = new SimplyDiscord();
```

### Command Structure Example:

```js
module.exports = {
  name: 'ping',
  aliases: ['p'],
  category: 'Utils',
  cooldown: 10, /* In seconds, this example is 10 seconds */
  async run ({ client, handler, message, args }) {
    // Your command code ...
  }
};
```

### Event Structure Example:

```js
module.exports = {
  name: 'ready',
  once: true,
  async run (client, handler, EVENT_PARAMS) {
    /* 
       EVENT_PARAMS are any params from the event itself, 
        check the Discord.js Docs for more info.
    */ 
  }
};
```
## TODO

<details open="open">
  <summary>Future Ideas</summary>
  <ol>
    <li>
      <a> Look into finding a better way to handle the guild checking.</a>
      <ul>
        <li><a> Relates to index.js Message event get prefix.</a></li>
      </ul>
    </li>
    <li><a>Add setCooldown(time, guildWide) set the time and if to apply to everyone in the guild.</a></li>
    <li><a>Add toggleCooldown(true) set the cooldown to True/False or toggle on/off</a></li>
  </ol>
</details>

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