DocsBasic vs Advanced Commands
Basic vs Advanced Commands
Understanding the difference between basic and advanced commands in meowcord.
Basic Commands
Basic commands are simple to use and are triggered when a user types your bot's prefix followed by the command name. They handle the command parsing for you automatically.
index.js
bot.basicCommand({
cmdName: "ping",
cmdCode: async (message) => {
message.reply("Pong!");
}
});
Features of basic commands:
- Automatic command name detection
- Support for command aliases
- Simple implementation
- Good for standard command patterns
Advanced Commands
Advanced commands give you complete control over how your commands are processed. They are useful for implementing complex command systems or custom parsing logic.
index.js
bot.advancedCommand({
cmdName: "custom-handler",
cmdCode: async (message) => {
const content = message.content.toLowerCase();
// You can implement any custom logic here
if (content.startsWith(bot.prefix + "hello")) {
message.reply("Hello there!");
} else if (content.startsWith(bot.prefix + "bye")) {
message.reply("Goodbye!");
} else if (content.includes("thanks") && message.mentions.users.has(bot.client.user.id)) {
message.reply("You're welcome!");
}
}
});
Features of advanced commands:
- Complete control over command detection
- Can handle multiple command patterns in a single handler
- Can respond to patterns that aren't standard commands
- Good for implementing custom command systems
When to Use Each Type
Here are some guidelines on when to use each type of command:
Use Basic Commands When:
- You want a simple command that responds to a specific command name
- You want to leverage the built-in command system
- You want your commands to show up in the help command automatically
- You're building a straightforward bot with standard command patterns
Use Advanced Commands When:
- You need complex command parsing logic
- You want to handle multiple command patterns in a single handler
- You're implementing a custom command system
- You need to respond to patterns that aren't standard commands
- You want complete control over how messages are processed
Combining Both Approaches
You can use both basic and advanced commands in the same bot. This allows you to leverage the simplicity of basic commands for standard functionality while using advanced commands for more complex features.
index.js
// Basic command for simple functionality
bot.basicCommand({
cmdName: "ping",
cmdCode: async (message) => {
message.reply("Pong!");
}
});
// Advanced command for complex functionality
bot.advancedCommand({
name: "message-responder",
cmdCode: async (message) => {
// Ignore messages from bots
if (message.author.bot) return;
// Ignore messages that are commands (they'll be handled by basic commands)
if (message.content.startsWith(bot.prefix)) return;
// Custom logic for non-command messages
if (message.content.includes("hello") && !message.content.startsWith(bot.prefix)) {
message.reply("Hello there! If you need help, try using commands with the prefix.");
}
}
});