@power-bots/powerbotlibrary 0.0.4 → 0.0.5
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.d.ts +3 -0
- package/dist/main.js +7 -7
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -47,8 +47,8 @@ class Bot {
|
|
|
47
47
|
discord_js_1.GatewayIntentBits.MessageContent
|
|
48
48
|
] });
|
|
49
49
|
// IMPORT COMMANDS
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
this.commands = new discord_js_1.Collection();
|
|
51
|
+
this.commandsArray = [];
|
|
52
52
|
const foldersPath = node_path_1.default.join(dirname, 'commands');
|
|
53
53
|
const commandFolders = node_fs_1.default.readdirSync(foldersPath);
|
|
54
54
|
for (const folder of commandFolders) {
|
|
@@ -65,8 +65,8 @@ class Bot {
|
|
|
65
65
|
const command = require(filePath);
|
|
66
66
|
if ('data' in command && 'execute' in command) {
|
|
67
67
|
this.log.info(`"${command.data.name}" command was imported from ${filePath}`);
|
|
68
|
-
commands.set(command.data.name, command);
|
|
69
|
-
commandsArray.push(command.data.toJSON());
|
|
68
|
+
this.commands.set(command.data.name, command);
|
|
69
|
+
this.commandsArray.push(command.data.toJSON());
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
72
|
this.log.warn(`The command at ${filePath} is missing a required "data" or "execute" property.`);
|
|
@@ -83,8 +83,8 @@ class Bot {
|
|
|
83
83
|
const rest = new discord_js_1.REST().setToken(botToken);
|
|
84
84
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
85
85
|
try {
|
|
86
|
-
this.log.info(`Started refreshing ${commandsArray.length} application (/) commands.`);
|
|
87
|
-
const data = yield rest.put(discord_js_1.Routes.applicationCommands(readyClient.user.id), { body: commandsArray });
|
|
86
|
+
this.log.info(`Started refreshing ${this.commandsArray.length} application (/) commands.`);
|
|
87
|
+
const data = yield rest.put(discord_js_1.Routes.applicationCommands(readyClient.user.id), { body: this.commandsArray });
|
|
88
88
|
this.log.info(`Successfully reloaded ${data.length} application (/) commands.`);
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
@@ -99,7 +99,7 @@ class Bot {
|
|
|
99
99
|
this.client.on(discord_js_1.Events.InteractionCreate, (interaction) => __awaiter(this, void 0, void 0, function* () {
|
|
100
100
|
try {
|
|
101
101
|
if (interaction.isChatInputCommand()) {
|
|
102
|
-
const command = commands.get(interaction.commandName);
|
|
102
|
+
const command = this.commands.get(interaction.commandName);
|
|
103
103
|
if (!command) {
|
|
104
104
|
this.log.error(`No command matching ${interaction.commandName} was found.`);
|
|
105
105
|
return;
|