Slash Command Loader
Easy to use and very flexible for complex slash command structures.
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
Create A Slash Command
Let's put this file in commands/ping.ts
(or .js if you're using JavaScript):
import { SlashCommand } from "slash-command-loader";
export default new SlashCommand({
api: {
name: "ping",
description: "A simple ping command!"
}
})
How To Load Slash Commands
Usage 1
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
)
Usage 2
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
)