spacecommands 3.4.2 → 3.4.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/CommandHandler.js +18 -2
- package/dist/SlashCommands.js +3 -3
- package/package.json +1 -1
package/dist/CommandHandler.js
CHANGED
|
@@ -44,7 +44,14 @@ class CommandHandler {
|
|
|
44
44
|
_commandChecks = new Map();
|
|
45
45
|
constructor(instance, client, dir, disabledDefaultCommands, typeScript = false) {
|
|
46
46
|
this._client = client;
|
|
47
|
-
|
|
47
|
+
if (client.isReady()) {
|
|
48
|
+
this.setUp(instance, client, dir, disabledDefaultCommands, typeScript);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
client.once('ready', () => {
|
|
52
|
+
this.setUp(instance, client, dir, disabledDefaultCommands, typeScript);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
56
|
async setUp(instance, client, dir, disabledDefaultCommands, typeScript = false) {
|
|
50
57
|
// Do not pass in TS here because this should always compiled to JS
|
|
@@ -163,7 +170,16 @@ class CommandHandler {
|
|
|
163
170
|
// Extract options from SlashCommandBuilder if using data property
|
|
164
171
|
// This allows commands to use SlashCommandBuilder pattern while still working with SpaceCommands
|
|
165
172
|
let finalOptions = options;
|
|
166
|
-
if (configuration.data && configuration.data.
|
|
173
|
+
if (configuration.data && typeof configuration.data.toJSON === 'function') {
|
|
174
|
+
const jsonData = configuration.data.toJSON();
|
|
175
|
+
if (jsonData.options) {
|
|
176
|
+
finalOptions = jsonData.options;
|
|
177
|
+
}
|
|
178
|
+
if (instance.debug && finalOptions && finalOptions.length) {
|
|
179
|
+
console.log(`SpaceCommands > Command "${name || fileName}" using SlashCommandBuilder with ${finalOptions.length} options`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else if (configuration.data && configuration.data.options) {
|
|
167
183
|
finalOptions = configuration.data.options;
|
|
168
184
|
if (instance.debug) {
|
|
169
185
|
console.log(`SpaceCommands > Command "${name || fileName}" using SlashCommandBuilder with ${finalOptions.length} options`);
|
package/dist/SlashCommands.js
CHANGED
|
@@ -109,9 +109,9 @@ class SlashCommands {
|
|
|
109
109
|
}
|
|
110
110
|
didOptionsChange(command, options) {
|
|
111
111
|
return (command.options?.filter((opt, index) => {
|
|
112
|
-
return (opt?.required !== options[index]?.required
|
|
113
|
-
opt?.name !== options[index]?.name
|
|
114
|
-
opt?.options
|
|
112
|
+
return (opt?.required !== options[index]?.required ||
|
|
113
|
+
opt?.name !== options[index]?.name ||
|
|
114
|
+
(opt?.options && opt.options.length !== options[index]?.options?.length));
|
|
115
115
|
}).length !== 0);
|
|
116
116
|
}
|
|
117
117
|
async create(name, description, options, guildId) {
|