Commandhandler
a simple discord.js v14 command framework
Install / Use
/learn @pierokchad/CommandhandlerREADME
✨ Discord.js v14 command framework
This is a simple and unique package which makes creating commands using .js and .ts a whole lot easier and make the code look cleaner.
[!CAUTION] Some features may not work properly as the project is no longer actively maintained.
🚀 Installation
1. Install package:
# npm
npm install @pierok/commandhandler
# yarn
yarn add @pierok/commandhandler
# pnpm
pnpm install @pierok/commandhandler
<bt></br> 2. In your command file, require the following:
JavaScript:
const { Command } = require('@pierok/commandhandler');
TypeScript:
import { Command, CommandOptions, RunOptions } from '@pierok/commandhandler';
<bt></br>
📑 Code example - command format
JavaScript:
const { Command } = require('@pierok/commandhandler');
const { Client, CommandInteraction, ApplicationCommandType } = require('discord.js');
module.exports = new Command({
name: "example",
description: "An example command",
type: ApplicationCommandType.ChatInput,
/**
* @param {Object} options
* @param {Client} options.client
* @param {CommandInteraction} options.interaction
* @param {Array<string>} options.args
*/
async run({ client, interaction, args }) {
await interaction.reply("Hello world!");
},
});
TypeScript:
import { Command, CommandOptions, RunOptions } from '@pierok/commandhandler';
import { Client, CommandInteraction, ApplicationCommandType } from 'discord.js';
const commandOptions: CommandOptions = {
name: "example",
description: "An example command",
type: ApplicationCommandType.ChatInput,
/**
* @param {RunOptions} options
*/
async run({ client, interaction, args }: RunOptions) {
await interaction.reply("Hello world!");
},
};
export default new Command(commandOptions);
📑 Code example - subcommand format
JavaScript:
const { Command } = require('@pierok/commandhandler');
const { Client, CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType } = require('discord.js');
module.exports = new Command({
name: "subcommand",
description: "A command with subcommands",
type: ApplicationCommandType.ChatInput,
options: [
{
name: "subcommand",
description: "A subcommand",
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: "input",
description: "Input value",
type: ApplicationCommandOptionType.String,
required: true
}
]
}
],
/**
* @param {Object} options
* @param {Client} options.client
* @param {CommandInteraction} options.interaction
* @param {Array<string>} options.args
*/
async run({ client, interaction, args }) {
await interaction.reply(`Subcommand executed with args: ${args.join(', ')}`);
},
});
TypeScript:
import { Command, CommandOptions, RunOptions } from '@pierok/commandhandler';
import { Client, CommandInteraction, ApplicationCommandType, ApplicationCommandOptionType } from 'discord.js';
const commandOptions: CommandOptions = {
name: "subcommand",
description: "A command with subcommands",
type: ApplicationCommandType.ChatInput,
options: [
{
name: "subcommand",
description: "A subcommand",
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: "input",
description: "Input value",
type: ApplicationCommandOptionType.String,
required: true
}
]
}
],
/**
* @param {RunOptions} options
*/
async run({ client, interaction, args }: RunOptions) {
await interaction.reply(`Subcommand executed with args: ${args.join(', ')}`);
},
};
export default new Command(commandOptions);
[!NOTE] If you have any bugs, please submit them here.
[!NOTE] You can contribute if you want.
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
