Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gary50613/discord.js-command-handler

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gary50613/discord.js-command-handler - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

5

doc/README-zh.md

@@ -44,4 +44,7 @@ # djs-command-handler

// 註冊整個資料夾的指令
commandHandler.commands.loadCommands("./commands")
// 註冊一個指令
commandHandler.commands.register(ping)
commandHandler.commands.register(new ping())

@@ -48,0 +51,0 @@ // 或是一次註冊多個指令

26

manager/CommandManager.js

@@ -0,1 +1,2 @@

const fs = require("fs");
const Group = require("../Base/Group");

@@ -14,6 +15,4 @@

register(command) {
if(Array.isArray(command))
return command.forEach(this.register)
if(Array.isArray(command)) command.forEach(cmd => this.register(cmd));
command = new command()
this.commands.push(command)

@@ -32,2 +31,23 @@

/**
* @description Register commands in folder
* @param {String} folderPath Path to folder
* @example commandHandler.commands.loadCommands("./commands")
*/
loadCommands(folderPath) {
if (typeof folderPath === "string")
throw new TypeError(`folderPath must be string, received ${typeof folderPath}`)
fs.readdir(folderPath, (err, files) => {
if (err) return console.error(err)
files.filter(f => f.endsWith(".js"))
.forEach(file =>
this.register(
new (require(`${folderPath}${folderPath.endsWith("/") ? "" : "/"}${file}`))()
)
)
})
}
/**
* @description return command by name or alias

@@ -34,0 +54,0 @@ * @param name command's name or alias

{
"name": "@gary50613/discord.js-command-handler",
"version": "1.3.0",
"version": "1.4.0",
"description": "simple discord.js command handler",

@@ -5,0 +5,0 @@ "main": "CommandHandler.js",

@@ -44,4 +44,7 @@ # djs-command-handler

// load a whole folder's commands
commandHandler.commands.loadCommands("./commands")
// register a command
commandHandler.commands.register(ping)
commandHandler.commands.register(new ping())

@@ -48,0 +51,0 @@ // or register multiple command at the same time

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc