Features | Parameters | Examples | I need...
- Command interface.
- Arguments interface.
- Permissions interface.
- Parameters.
- Element validator.
- Argument validator.
- Add cooldown in commands.
function readCommands(
//Prefix that calls the bot.
prefix: string,
//Message from discord.
message: any
): Promise<void>; //Type of value returned.
function readFiles(
//Bot directory
directory: string,
//Command directory
target: string
): Promise<void>; //Type of value returned.
interface TypeCommand {
//Name of the command to be executed.
name: string, //Value to be received.
//Alternative names of the command to run.
aliases: null | string[], //Value to be received.
//Command category.
category: null | string[], //Value to be received.
//The command will be executed if true.
activated: boolean; //Value to be received.
}
interface TypeArgs {
//Argument type to send.
expectedArgs: null | string[], //Value to be received.
//Number of arguments.
numberOfArgs: null | number, //Value to be received.
//The command is not executed if the arguments are greater than those requested.
NotMoreArgs: boolean, //Value to be received.
//Parameters of the arguments to send if there is an error.
argsError: null | string, //Value to be received.
//Minimum number of arguments.
minArgs: null | number, //Value to be received.
//Maximum number of arguments.
maxArgs: null | number; //Value to be received.
};
interface TypePerms {
//It will find if a user has the roles or the permissions.
alternative: boolean, //Value to be received.
//Required roles to run the commando.
requiredRoles: null | string[], //Value to be received.
//Required permissions to run the commando.
requiredPerms: null | string[]; //Value to be received.
};
{
"devDependencies": {
"@types/node": "^14.14.37",
"dotenv": "^8.2.0",
"nodemon": "^2.0.7",
"typescript": "^4.2.4"
},
"dependencies": {
"@flamesx_128/discord.js_cmds": "^3.0.0",
"discord.js": "^12.5.3"
}
}
import { config } from 'dotenv';
config();
import { readCommands, readFiles } from '@flamesx_128/discord.js_cmds';
import { Client, Message } from 'discord.js';
const client = new Client();
const prefix = "!";
client.on('ready', async () => {
await readFiles(__dirname, 'commands');
console.log('Bot ready!');
});
client.on('message', async (message: Message) => {
if (message.author.bot) return;
await readCommands(prefix, message);
});
client.login(process.env.BOT);
import { commandBase } from '@flamesx_128/discord.js_cmds';
module.exports = new class cmdPing extends commandBase {
constructor() {
super();
this.Command = {
name: 'ping',
aliases: null,
category: ['fun'],
activated: true
};
};
async execute(prefix: string, message: any, args: string[]) {
message.reply(`Pong! \nAPI latency: ${message.client.ws.ping}ms.`);
};
};
{
"dependencies": {
"@flamesx_128/discord.js_cmds": "^3.0.0",
"discord.js": "^12.5.3"
}
}
const { readFiles, readCommands } = require('@flamesx_128/discord.js_cmds');
const { Client } = require("discord.js");
const client = new Client();
const prefix = "$";
client.on("ready", async () => {
await readFiles(__dirname, "cmds");
});
client.on("message", async (message) => {
if (message.author.bot) return;
if (message.content.startsWith(!prefix)) return;
await readCommands(prefix, message);
});
client.login("SECRET TOKEN");
const { commandBase } = require('@flamesx_128/discord.js_cmds');
module.exports = new class Ping extends commandBase {
constructor(Command){
super(Command);
this.Command = {
name: "ping",
aliases: null,
category: null,
activated: true
};
};
execute = (prefix, message, args) => {
message.channel.send("Pong!");
};
};