Skip to content

Commit 21a4076

Browse files
committed
Bug: new commands aren't registered
1 parent df2d7c1 commit 21a4076

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

index.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class cDClient extends Client {
4545
return;
4646
}
4747

48-
const clientId = this.user.id;
48+
const clientId = this.application.id;
4949
let commands = [];
5050
let privateCommands = [];
5151

@@ -57,9 +57,9 @@ class cDClient extends Client {
5757
for (const file of commandFiles) {
5858
const filePath = path.join(commandsPath, file);
5959
const command = require(filePath);
60-
if (!("data" in command) || !("run" in command)) {
60+
if (!("data" in command)) {
6161
console.error(
62-
`- Command '${command.name}' is missing the 'data' or 'run' property!`
62+
`- Command '${command.name}' is missing the 'data' property!`
6363
);
6464
continue;
6565
} else if (Boolean(command.ignore || false)) {
@@ -68,7 +68,7 @@ class cDClient extends Client {
6868
continue;
6969
}
7070

71-
if ((command.guildIds || []).length > 0) {
71+
if ((command.guildIds ?? []).length > 0) {
7272
privateCommands.push({
7373
data: command.data,
7474
guildIds: command.guildIds,
@@ -91,21 +91,29 @@ class cDClient extends Client {
9191
`🔁 Started refreshing ${commands.length} global and ${privateCommands.length} guild commands.`
9292
);
9393

94-
// TODO: Fix that currentCommands is correct
9594
let currentCommands = this.application.commands.cache;
95+
console.log(currentCommands);
9696
if (!currentCommands.size)
9797
if (this.isReady()) {
98-
currentCommands = await this.application.commands.fetch();
98+
currentCommands = await this.application.commands.fetch({
99+
cache: true,
100+
});
101+
console.log("1", currentCommands);
99102
} else {
100103
currentCommands = await rest.get(
101104
`/applications/${clientId}/commands`
102105
);
106+
console.log("2", currentCommands);
103107
}
104108

105109
const _new = [];
106110
const updated = [];
107111
const toDelete = [];
108112

113+
currentCommands.forEach((cmd) =>
114+
console.log("currentCommand", cmd)
115+
);
116+
commands.forEach((cmd) => console.log("command", cmd));
109117
// Initialising
110118
for (const command of commands) {
111119
if (!currentCommands.some((c) => c.name == command.name)) {
@@ -143,11 +151,15 @@ class cDClient extends Client {
143151

144152
if (logOptions.status)
145153
console.log(`🔁 Creating ${_new.length} global commands...`);
154+
_new.forEach((cmd) => console.log("_new", cmd));
155+
console.log("rest", rest);
156+
console.log("token", rest.token);
146157
for (let cmd of _new) {
147158
data = await rest.post(`/applications/${clientId}/commands`, {
148159
body: cmd,
149160
});
150-
if (logOptions.created) console.log(`✔️ Created '${cmd.name}'`);
161+
if (logOptions.created)
162+
console.log(`✔️ Created '${data.name}'`);
151163
}
152164

153165
if (logOptions.status)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "djs-command-deployer",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "",
55
"main": "./index.js",
66
"scripts": { },

0 commit comments

Comments
 (0)