A small module used to handle commands using DiscordJS.
npm install icytea-command-handlerA small module used to handle commands using DiscordJS.
To use this module, simply apply the code below.
Typesript:
``ts
import { CommandHandler } from "icytea-command-handler";
// Remember to put this code inside an async function.
await new CommandHandler(client, options).init();
`
Javascript/NodeJS:
`js
const { CommandHandler } = require("icytea-command-handler");
// Remember to put this code inside an async function.
await new CommandHandler(client, options).init();
`
To create a command, look at this example. This package will utilize Discord's Slash commands. Please refer to DiscordJS Documentation or Official Discord Developers Documentation for more information on slash commands.
Typescript:
`ts
import { CommandTemplate } from "icytea-command-handler";
// Replace "Help" with the name of the command you like.
export default class Help extends CommandTemplate {
constructor() {
super({
data: {
name: "help",
description: "The help command.",
}, // Fill in basic data of the command.
ownerOnly: false,
userPermissions: [], // Sets the user's permissions
clientPermissions: [], // Sets the client's permissions
callback: ({
interaction,
client,
guild,
member,
user,
options,
channel,
handler,
}) => {
// Execute the command.
},
});
}
}
`
Javascript/NodeJS:
`js
const { CommandTemplate } = require("icytea-command-handler");
// Replace "Help" with the name of the command you like.
module.exports = class Help extends CommandTemplate {
constructor() {
super({
data: {
name: "help",
description: "The help command.",
}, // Fill in basic data of the command.
ownerOnly: false,
userPermissions: [], // Sets the user's permissions
clientPermissions: [], // Sets the client's permissions
callback: ({
interaction,
client,
guild,
member,
user,
options,
channel,
handler,
}) => {
// Execute the command.
},
});
}
};
`
To create a feature, simply use this code below.
Typescript:
`ts
import { FeatureTemplate } from "icytea-command-handler";
// Replace "Feature" with the name of the feature you like.
export default class Feature extends FeatureTemplate {
public static shared = new Feature();
public async init(client: Client): Promise
}
`
Javascript/NodeJS:
`ts
const { FeatureTemplate } = require("icytea-command-handler");
// Replace "Feature" with the name of the feature you like.
module.exports = class Feature extends FeatureTemplate {
static shared = new Feature();
async init(client) {}
};
``