-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcommandCheck.js
More file actions
37 lines (30 loc) · 1.05 KB
/
Copy pathcommandCheck.js
File metadata and controls
37 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const checkCommandModule = (cmdName, cmdModule) => {
if (!cmdModule.hasOwnProperty("execute"))
throw new Error(
`${cmdName} command module does not have property 'execute'`
);
if (!cmdModule.hasOwnProperty("description"))
throw new Error(
`${cmdName} command module does not have property 'description`
);
if (!cmdModule.hasOwnProperty("aliases"))
throw new Error(
`${cmdName} command module does not have property 'aliases'`
);
return true;
};
const checkCommandProperties = (cmdName, cmdModule) => {
if (typeof cmdModule.execute !== "function")
throw new Error(`${cmdName} command: execute is not a function`);
if (typeof cmdModule.description !== "string")
throw new Error(`${cmdName} command: description is not a string`);
if (!Array.isArray(cmdModule.aliases))
throw new Error(`${cmdName} command: aliases is not an Array`);
return true;
};
module.exports = (cmdName, cmdModule) => {
return (
checkCommandModule(cmdName, cmdModule) &&
checkCommandProperties(cmdName, cmdModule)
);
};