0.2.4 • Published 4 years ago
cmdhandler.js v0.2.4
cmdhandler.js
Description
Easy command handling for discord.js
Table of contents
About
command handler for discord.js bot project
Badge
Install
npm i cmdhandler.js --save
Example
Setup
const Discord = require("discord.js");
const client = new Discord.Client();
const cmdHandler = require("cmdhandler.js");
const handler = new cmdHandler.Handler({
folder: "./commands", //required
client: client, //required
prefix: "!", //required
owner: ["Your Id"], //required , optional add more owner Id
});
handler.start();
client.login("YOUR_TOKEN_HERE");
Standart using example
//"./commands/general/ping.js"
const Discord = require("discord.js");
module.exports = {
name: "ping",
description: "Ping!", //description :P
//Be careful
code: (message, args, client) => {
//Your code here
message.channel.send("Pong");
},
};
Cooldown example
//"./commands/general/ping.js"
const Discord = require("discord.js");
module.exports = {
name: "ping",
// Deleteable and error message is optional
cooldown: {
time: 3,
errorMsg:
"You can use the command named `{command.name}` after {time} seconds.",
deletable: true,
},
description: "Ping!", //description :P
//Be careful
code: (message, args, client) => {
//Your code here
message.channel.send("Pong");
},
};
Aliases example
//"./commands/general/ping.js"
const Discord = require("discord.js");
module.exports = {
name: "ping",
aliases: ["delay"],
description: "Ping!", //description :P
//Be careful
code: (message, args, client) => {
//Your code here
message.channel.send("Pong");
},
};
Guild only command example
//"./commands/general/server-icon.js"
const Discord = require("discord.js");
module.exports = {
name: "server-icon",
// Deletable and error message is optional
guildOnly: {
status: true,
errorMsg: "{user.name},you cannot use this command in DM",
deletable: true,
},
description: "look server icon", //description :P
//Be careful
code: (message, args, client) => {
//Your code here
message.channel.send(
message.guild.iconURL({ display: true, format: "png" })
);
},
};
Owner only command example
//"./commands/general/server-icon.js"
const Discord = require("discord.js");
module.exports = {
name: "server-icon",
ownerOnly: {
status: true,
errorMsg: "<@{user.id}>, this command for my owner(s)",
deletable: false,
},
description: "look server icon", //description :P
//Be careful
code: (message, args, client) => {
//Your code here
message.channel.send(
message.guild.iconURL({ display: true, format: "png" })
);
},
};
Require permission & Require args
//"./commands/moderator/ban.js"
const Discord = require("discord.js");
module.exports = {
name: "ban",
permission: {
perm: "BAN_MEMBERS",
errorMsg: "You must have '{perm}' permission to use this command.",
deletable: true,
},
args: 1,
description: "You can ban a member", //description :P
//Be careful
code: (message, args, client) => {
//Your code here
message.guild.member.ban(message.mention.first());
},
};
Keys
- {user.id} - return
message.author.id
- {user.name} - return
message.author.username
- {user.discrim} - return
message.author.discriminator
- {command.name} - return used command name
- {time} - return left time from cooldowns (only cooldowns)
- {perm} - return require perm for use command (only for require permission)
0.2.5-v13-message-0.2
4 years ago
0.2.5-v13-message
4 years ago
0.2.1
4 years ago
0.2.0
4 years ago
0.2.3
4 years ago
0.2.2
4 years ago
0.2.4
4 years ago
0.1.2
4 years ago
0.1.4
4 years ago
0.1.3
4 years ago
0.1.5
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago
0.0.9
4 years ago
0.0.8
4 years ago
0.0.7
4 years ago
0.0.6
4 years ago
0.0.5
4 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago