# @ruben40000/slash-command-loader

> Simple and easy to use slash command loader for complex json structures.

Latest version **2.0.2** (published 2022-08-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install @ruben40000/slash-command-loader
pnpm add @ruben40000/slash-command-loader
yarn add @ruben40000/slash-command-loader
bun add @ruben40000/slash-command-loader
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2022-08-26 |
| First published | 2022-08-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 62.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ruben40000 |
| Maintainers | ruben40000 |

## Links

- npm: https://www.npmjs.com/package/@ruben40000/slash-command-loader
- npm.io page: https://npm.io/package/@ruben40000/slash-command-loader

## Recent versions

- 2.0.2 (latest) — 2022-08-26
- 2.0.1 — 2022-08-26
- 2.0.0 — 2022-08-26
- 1.0.5 — 2022-08-24
- 1.0.4 — 2022-08-24
- 1.0.3 — 2022-08-24
- 1.0.2 — 2022-08-24
- 1.0.1 — 2022-08-21
- 1.0.0 — 2022-08-16

## README

# Slash Command Loader
<strong> Easy to use and very flexible for complex slash command structures. </strong> <br>

## How It Works
Simply put, it loads files from given directory, and attempts to put them in either slash commands, slash commands with sub commands, or slash commands with subcommand groups:

`directory/myslashdata.js` => slash command
`directory/folder(s)/myslashdata.js` => slash command with subcommands
`directory/folder(s)/folder(s)/myslashdata.js` => slash command with subcommand groups

## <strong> Create A Slash Command </strong>
Let's put this file in `commands/ping.ts` (or .js if you're using JavaScript):
```ts
import { SlashCommand } from "slash-command-loader"; 

export default new SlashCommand({
    api: {
        name: "ping",
        description: "A simple ping command!"
    }
})
```

# <strong> How To Load Slash Commands </strong>

## <strong> Usage 1 </strong>
```ts
import { SlashCommandLoader } from "slash-command-loader";

// Put your commands directory in the first parameter
new SlashCommandLoader("./commands")
    .loadAsync()
    .then(
        manager => console.log(manager.toJSON()) // Array of application command data, this can be pushed directly to the Discord API
    )
```
## <strong> Usage 2 </strong>
```ts
import { SlashCommandLoader } from "slash-command-loader";

// Put your commands directory in the first parameter
new SlashCommandLoader("./commands")
    .load(
        manager => console.log(manager.toJSON()) // Array of application command data, this can be pushed directly to the Discord API
    )
```

---
_Source: https://npm.io/package/@ruben40000/slash-command-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
