djs-commander
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -7,2 +7,8 @@ # Change Log | ||
## [0.0.39] - 2023-02-24 | ||
### Fixed | ||
- Incomplete `commandObj` in validation files | ||
## [0.0.38] - 2023-02-20 | ||
@@ -9,0 +15,0 @@ |
@@ -7,4 +7,3 @@ const { getFolderPaths, getFilePaths } = require('./utils/getPaths'); | ||
constructor({ client, commandsPath, eventsPath, validationsPath, testServer }) { | ||
if (!client) | ||
throw new Error('Property "client" is required when instantiating CommandHandler.'); | ||
if (!client) throw new Error('Property "client" is required when instantiating CommandHandler.'); | ||
@@ -45,5 +44,19 @@ this._client = client; | ||
let commandsToRegister = JSON.parse(JSON.stringify(commands)); | ||
commandsToRegister.forEach((cmd) => { | ||
delete cmd['deleted']; | ||
delete cmd['run']; | ||
let fieldsToSend = [ | ||
'name', | ||
'options', | ||
'name_localizations', | ||
'description', | ||
'description_localizations', | ||
'default_permission', | ||
'default_member_permissions', | ||
'dm_permission', | ||
]; | ||
commandsToRegister = commandsToRegister.map((cmd) => { | ||
const filteredKeys = Object.keys(cmd).filter((key) => fieldsToSend.includes(key)); | ||
return filteredKeys.reduce((obj, key) => { | ||
obj[key] = cmd[key]; | ||
return obj; | ||
}, {}); | ||
}); | ||
@@ -50,0 +63,0 @@ |
@@ -73,3 +73,3 @@ var __defProp = Object.defineProperty; | ||
for (const commandFilePath of commandFilePaths) { | ||
const { data, run, deleted } = require(commandFilePath); | ||
const { data, run, deleted, ...rest } = require(commandFilePath); | ||
if (!data) | ||
@@ -85,2 +85,3 @@ throw new Error(`File ${commandFilePath} must export "data".`); | ||
...data, | ||
...rest, | ||
deleted: deleted || null, | ||
@@ -224,5 +225,18 @@ run | ||
let commandsToRegister = JSON.parse(JSON.stringify(commands)); | ||
commandsToRegister.forEach((cmd) => { | ||
delete cmd["deleted"]; | ||
delete cmd["run"]; | ||
let fieldsToSend = [ | ||
"name", | ||
"options", | ||
"name_localizations", | ||
"description", | ||
"description_localizations", | ||
"default_permission", | ||
"default_member_permissions", | ||
"dm_permission" | ||
]; | ||
commandsToRegister = commandsToRegister.map((cmd) => { | ||
const filteredKeys = Object.keys(cmd).filter((key) => fieldsToSend.includes(key)); | ||
return filteredKeys.reduce((obj, key) => { | ||
obj[key] = cmd[key]; | ||
return obj; | ||
}, {}); | ||
}); | ||
@@ -229,0 +243,0 @@ this._commandsToRegister = commandsToRegister; |
{ | ||
"name": "djs-commander", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"description": "A command and event handler that works seemlessly with Discord.js", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
31896
744