Skip to content

Commit bb99226

Browse files
committed
fix commandData type
1 parent 08c7e9f commit bb99226

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

packages/commandkit/src/handlers/command-handler/functions/registerCommands.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,44 @@ export default async function registerCommands(commandHandler: CommandHandler) {
3838
}
3939

4040
for (const command of commands) {
41+
let commandData = command.data as any;
42+
4143
// <!-- Delete command if options.deleted -->
4244
if (command.options?.deleted) {
4345
const targetCommand = appCommands?.cache.find(
44-
(cmd) => cmd.name === command.data.name,
46+
(cmd) => cmd.name === commandData.name,
4547
);
4648

4749
if (!targetCommand) {
4850
console.log(
4951
colors.yellow(
50-
`⏩ Ignoring: Command "${command.data.name}" is globally marked as deleted.`,
52+
`⏩ Ignoring: Command "${commandData.name}" is globally marked as deleted.`,
5153
),
5254
);
5355
} else {
5456
targetCommand.delete().then(() => {
5557
console.log(
56-
colors.green(`🚮 Deleted command "${command.data.name}" globally.`),
58+
colors.green(`🚮 Deleted command "${commandData.name}" globally.`),
5759
);
5860
});
5961
}
6062

6163
for (const guildCommands of devGuildCommands) {
6264
const targetCommand = guildCommands.cache.find(
63-
(cmd) => cmd.name === command.data.name,
65+
(cmd) => cmd.name === commandData.name,
6466
);
6567

6668
if (!targetCommand) {
6769
console.log(
6870
colors.yellow(
69-
`⏩ Ignoring: Command "${command.data.name}" is marked as deleted for ${guildCommands.guild.name}.`,
71+
`⏩ Ignoring: Command "${commandData.name}" is marked as deleted for ${guildCommands.guild.name}.`,
7072
),
7173
);
7274
} else {
7375
targetCommand.delete().then(() => {
7476
console.log(
7577
colors.green(
76-
`🚮 Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`,
78+
`🚮 Deleted command "${commandData.name}" in ${guildCommands.guild.name}.`,
7779
),
7880
);
7981
});
@@ -84,12 +86,11 @@ export default async function registerCommands(commandHandler: CommandHandler) {
8486
}
8587

8688
// <!-- Edit command -->
87-
let commandData = command.data;
8889
let editedCommand = false;
8990

9091
// Edit command globally
9192
const appGlobalCommand = appCommands?.cache.find(
92-
(cmd) => cmd.name === command.data.name,
93+
(cmd) => cmd.name === commandData.name,
9394
);
9495

9596
if (appGlobalCommand) {
@@ -163,31 +164,31 @@ export default async function registerCommands(commandHandler: CommandHandler) {
163164
if (!devGuilds.length) {
164165
console.log(
165166
colors.yellow(
166-
`⏩ Ignoring: Cannot register command "${command.data.name}" as no valid "devGuildIds" were provided.`,
167+
`⏩ Ignoring: Cannot register command "${commandData.name}" as no valid "devGuildIds" were provided.`,
167168
),
168169
);
169170
continue;
170171
}
171172

172173
for (const guild of devGuilds) {
173174
const cmdExists = guild.commands.cache.some(
174-
(cmd) => cmd.name === command.data.name,
175+
(cmd) => cmd.name === commandData.name,
175176
);
176177
if (cmdExists) continue;
177178

178179
guild?.commands
179-
.create(command.data)
180+
.create(commandData)
180181
.then(() => {
181182
console.log(
182183
colors.green(
183-
`✅ Registered command "${command.data.name}" in ${guild.name}.`,
184+
`✅ Registered command "${commandData.name}" in ${guild.name}.`,
184185
),
185186
);
186187
})
187188
.catch((error) => {
188189
console.log(
189190
colors.red(
190-
`❌ Failed to register command "${command.data.name}" in ${guild.name}.`,
191+
`❌ Failed to register command "${commandData.name}" in ${guild.name}.`,
191192
),
192193
);
193194
console.error(error);
@@ -196,20 +197,20 @@ export default async function registerCommands(commandHandler: CommandHandler) {
196197
}
197198
// Register command globally
198199
else {
199-
const cmdExists = appCommands?.cache.some((cmd) => cmd.name === command.data.name);
200+
const cmdExists = appCommands?.cache.some((cmd) => cmd.name === commandData.name);
200201
if (cmdExists) continue;
201202

202203
appCommands
203-
?.create(command.data)
204+
?.create(commandData)
204205
.then(() => {
205206
console.log(
206-
colors.green(`✅ Registered command "${command.data.name}" globally.`),
207+
colors.green(`✅ Registered command "${commandData.name}" globally.`),
207208
);
208209
})
209210
.catch((error) => {
210211
console.log(
211212
colors.red(
212-
`❌ Failed to register command "${command.data.name}" globally.`,
213+
`❌ Failed to register command "${commandData.name}" globally.`,
213214
),
214215
);
215216
console.error(error);

0 commit comments

Comments
 (0)