aoijs-command-manager-v2
v1.0.0
Published
A command manager for aoi.js that handles slash commands with ease.
Downloads
8
Maintainers
Readme
aoi-command-manager-v2
A command manager for aoi.js that handles slash commands with ease.
Features
- 🔄 Automatic command synchronization with Discord API
- 📁 easy way to create, edit a slash command
- ✅ Command validation and error checking
Installation
npm install aoi-command-manager-v2Quick Start
const { AoiClient } = require('aoi.js')
const { ApplicationCommandManager } = require('aoi-command-manager-v2')
const bot = new AoiClient({
token: "YOUR TOKEN",
prefix: "!",
intents: ["MessageContent", "Guilds", "GuildMessages"],
events: ["onMessage", "onInteractionCreate"],
database: {
type: "aoi.db",
db: require("@aoijs/aoi.db"),
dbType: "KeyValue",
tables: ["main"],
securityKey: "a-32-characters-long-string-here"
}
});
// Initialize the command manager
new ApplicationCommandManager(bot, {
path: './slashcommads', // Path to your commands directory
showTable: true, // Show command table (default: true)
validateCommands: true, // Validate commands (default: true)
checkUpdates: true // Check for updates (default: true)
})
client.loadCommands("./commands")Examples:
Command Structure
module.exports = {
name: 'ping',
type: 'slash',
prototype: "interaction",
code: `$interactionReply[My ping is $pingms]`
}Slash Structure
const { SlashCommandBuilder } = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription("shows the bot's ping")
}Configuration Options
| Option | Type | Default | Description | |--------|------|---------|-------------| | path | string |-| Path to commands directory | | showTable | boolean | true | Show command table after loading | | validateCommands | boolean | true | Validate commands before loading | | checkUpdates | boolean | true | Check for package updates |
Built-in Functions
$applicationCommandSync
Syncs commands with Discord API.
$applicationCommandSync[guildId1,guildId2] // Optional guild IDs$applicationCommandReload
Reloads all commands from the directory.
$applicationCommandReload$applicationCommandValidate
Validates all slash commands and displays any errors found.
$applicationCommandValidateExample output:
Slash Command Validation Errors:
❌ ping: Missing description
❌ help: Name must be between 1 and 32 characters
❌ settings: Option 'channel' missing descriptionCommand Table
The command table shows the status of each loaded command. If any errors are found, it will suggest running the validation function for detailed information.
Loaded Slash Commands
┌─────────┬────────┬───────┐
│ Name │ Status │ Error │
├─────────┼────────┼───────┤
│ ping │ ✅ │ │
│ help │ ❌ │ Missing description │
└─────────┴────────┴───────┘
⚠️ Some commands have errors. Run $applicationCommandValidate to see detailed validation results.License
MIT
