icytea-command-handler
v1.0.50
Published
A small module used to handle commands using DiscordJS.
Downloads
63
Readme
icytea-command-handler
A small module used to handle commands using DiscordJS.
Usage
Initiate the module
To use this module, simply apply the code below.
Typesript:
import { CommandHandler } from "icytea-command-handler";
// Remember to put this code inside an async function.
await new CommandHandler(client, options).init();
Javascript/NodeJS:
const { CommandHandler } = require("icytea-command-handler");
// Remember to put this code inside an async function.
await new CommandHandler(client, options).init();
Creating a command
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:
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:
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.
},
});
}
};
Creating a feature
To create a feature, simply use this code below.
Typescript:
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<void>;
}
Javascript/NodeJS:
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) {}
};