@power-bots/powerbotlibrary 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +22 -19
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -50,36 +50,39 @@ class Bot {
|
|
|
50
50
|
this.commands = new discord_js_1.Collection();
|
|
51
51
|
this.commandsArray = [];
|
|
52
52
|
const foldersPath = node_path_1.default.join(dirname, 'commands');
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
else {
|
|
61
|
-
commandFiles = [""];
|
|
62
|
-
}
|
|
63
|
-
for (const file of commandFiles) {
|
|
64
|
-
const filePath = node_path_1.default.join(commandsPath, file);
|
|
65
|
-
const command = require(filePath);
|
|
66
|
-
if ('data' in command && 'execute' in command) {
|
|
67
|
-
this.log.info(`"${command.data.name}" command was imported from ${filePath}`);
|
|
68
|
-
this.commands.set(command.data.name, command);
|
|
69
|
-
this.commandsArray.push(command.data.toJSON());
|
|
53
|
+
if (node_fs_1.default.existsSync(foldersPath)) {
|
|
54
|
+
const commandFolders = node_fs_1.default.readdirSync(foldersPath);
|
|
55
|
+
for (const folder of commandFolders) {
|
|
56
|
+
const commandsPath = node_path_1.default.join(foldersPath, folder);
|
|
57
|
+
let commandFiles;
|
|
58
|
+
if (node_fs_1.default.statSync(commandsPath).isDirectory()) {
|
|
59
|
+
commandFiles = node_fs_1.default.readdirSync(commandsPath).filter((file) => file.endsWith('.js'));
|
|
70
60
|
}
|
|
71
61
|
else {
|
|
72
|
-
|
|
62
|
+
commandFiles = [""];
|
|
63
|
+
}
|
|
64
|
+
for (const file of commandFiles) {
|
|
65
|
+
const filePath = node_path_1.default.join(commandsPath, file);
|
|
66
|
+
const command = require(filePath);
|
|
67
|
+
if ('data' in command && 'execute' in command) {
|
|
68
|
+
this.commands.set(command.data.name, command);
|
|
69
|
+
this.commandsArray.push(command.data.toJSON());
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.log.warn(`The command at ${filePath} is missing a required "data" or "execute" property.`);
|
|
73
|
+
}
|
|
74
|
+
;
|
|
73
75
|
}
|
|
74
76
|
;
|
|
75
77
|
}
|
|
76
78
|
;
|
|
77
79
|
}
|
|
78
|
-
;
|
|
79
80
|
// LOGIN CLIENT
|
|
80
81
|
this.client.once(discord_js_1.Events.ClientReady, (readyClient) => {
|
|
81
82
|
this.log.info(`Logged in as ${readyClient.user.tag}`);
|
|
82
83
|
// REGISTER COMMANDS
|
|
84
|
+
if (this.commandsArray.length === 0)
|
|
85
|
+
return;
|
|
83
86
|
const rest = new discord_js_1.REST().setToken(botToken);
|
|
84
87
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
85
88
|
try {
|