Commands
Create powerful slash commands with simple syntax.
Basic Command
commands/ping.js
bot.command.new('ping', 'Pong!', async function() {
await this.reply('Pong!');
});
Syntax
bot.command.new(name, description, handler)
- name - Command name (lowercase, no spaces)
- description - What the command does
- handler - Function to execute
Command Parameters
commands/greet.js
bot.command.new('greet', 'Greet someone', async function() {
const user = this.getUser('user') || this.user;
await this.reply(`Hello, ${user.username}!`);
}, [{
name: 'user',
description: 'User to greet',
type: 6, // User
required: false
}]);
Parameter Types
3- String4- Integer5- Boolean6- User7- Channel8- Role
Context API
Inside command handler, this contains:
Interaction Methods
this.reply(content)- Reply to commandthis.edit(content)- Edit replythis.defer()- Defer for long operationsthis.followUp(content)- Send follow-up
Data Access
this.user- Command userthis.guild- Current serverthis.channel- Current channelthis.client- Discord.js client
Parameter Getters
this.getString('name')- Get string paramthis.getInteger('amount')- Get integerthis.getUser('user')- Get userthis.getChannel('channel')- Get channel
Utilities
this.random.number(min, max)- Random numberthis.random.bool()- Random booleanthis.emoji- Custom emojisthis.vals- Global values
More Examples
Random Number
commands/dice.js
bot.command.new('dice', 'Roll a dice', async function() {
const num = this.random.number(1, 6);
await this.reply(`🎲 You rolled: ${num}`);
});
User Info with Embed
commands/info.js
bot.command.new('info', 'User info', async function() {
const user = this.getUser('user') || this.user;
await this.reply({
embeds: [{
title: `Info: ${user.username}`,
fields: [
{ name: 'ID', value: user.id },
{ name: 'Tag', value: user.tag }
]
}]
});
});