nuxt-discord 0.0.15 → 0.0.17

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.
@@ -1,6 +1,6 @@
1
- import type { APIApplicationCommand, ChatInputCommandInteraction, CommandInteraction, RESTGetAPIApplicationCommandsResult, RESTPutAPIApplicationCommandsResult } from 'discord.js';
2
- import type { NuxtDiscordOptions, SlashCommandRuntime } from '../../../types.js';
3
- import { Client as InternalClient } from 'discord.js';
1
+ import type { APIApplicationCommandOption, ChatInputCommandInteraction, CommandInteraction, RESTGetAPIApplicationCommandsResult, RESTPutAPIApplicationCommandsResult } from 'discord.js';
2
+ import type { NuxtDiscordOptions, SlashCommandRuntime, SlashCommandSubcommandGroupRuntime, SlashCommandSubcommandRuntime } from '../../../types.js';
3
+ import { ApplicationCommandOptionType, Client as InternalClient } from 'discord.js';
4
4
  export interface DiscordClientErrorBase {
5
5
  type: string;
6
6
  client: DiscordClient;
@@ -45,18 +45,243 @@ export declare class DiscordClient {
45
45
  getSlashCommand(name: string): SlashCommandRuntime | undefined;
46
46
  getRemoteSlashCommands(): Promise<RESTGetAPIApplicationCommandsResult>;
47
47
  diffRemoteSlashCommands(localCommands?: SlashCommandRuntime[], forceRefresh?: boolean): Promise<{
48
- added: SlashCommandRuntime[];
49
- removed: APIApplicationCommand[];
48
+ added: (SlashCommandRuntime | SlashCommandSubcommandRuntime | SlashCommandSubcommandGroupRuntime)[];
49
+ removed: ({
50
+ name: string;
51
+ subcommands: never[];
52
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
53
+ type: ApplicationCommandOptionType.Subcommand;
54
+ name_localizations?: import("discord.js").LocalizationMap | null;
55
+ description: string;
56
+ description_localizations?: import("discord.js").LocalizationMap | null;
57
+ required?: boolean;
58
+ } | {
59
+ name: string;
60
+ subcommands: {
61
+ name: string;
62
+ subcommands: never[];
63
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
64
+ type: ApplicationCommandOptionType.Subcommand;
65
+ name_localizations?: import("discord.js").LocalizationMap | null;
66
+ description: string;
67
+ description_localizations?: import("discord.js").LocalizationMap | null;
68
+ required?: boolean;
69
+ }[];
70
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
71
+ type: ApplicationCommandOptionType.SubcommandGroup;
72
+ name_localizations?: import("discord.js").LocalizationMap | null;
73
+ description: string;
74
+ description_localizations?: import("discord.js").LocalizationMap | null;
75
+ required?: boolean;
76
+ } | {
77
+ subcommands: ({
78
+ name: string;
79
+ subcommands: never[];
80
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
81
+ type: ApplicationCommandOptionType.Subcommand;
82
+ name_localizations?: import("discord.js").LocalizationMap | null;
83
+ description: string;
84
+ description_localizations?: import("discord.js").LocalizationMap | null;
85
+ required?: boolean;
86
+ } | {
87
+ name: string;
88
+ subcommands: {
89
+ name: string;
90
+ subcommands: never[];
91
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
92
+ type: ApplicationCommandOptionType.Subcommand;
93
+ name_localizations?: import("discord.js").LocalizationMap | null;
94
+ description: string;
95
+ description_localizations?: import("discord.js").LocalizationMap | null;
96
+ required?: boolean;
97
+ }[];
98
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
99
+ type: ApplicationCommandOptionType.SubcommandGroup;
100
+ name_localizations?: import("discord.js").LocalizationMap | null;
101
+ description: string;
102
+ description_localizations?: import("discord.js").LocalizationMap | null;
103
+ required?: boolean;
104
+ })[];
105
+ id: import("discord.js").Snowflake;
106
+ type: import("discord.js").ApplicationCommandType;
107
+ application_id: import("discord.js").Snowflake;
108
+ guild_id?: import("discord.js").Snowflake;
109
+ name: string;
110
+ name_localizations?: import("discord.js").LocalizationMap | null;
111
+ name_localized?: string;
112
+ description: string;
113
+ description_localizations?: import("discord.js").LocalizationMap | null;
114
+ description_localized?: string;
115
+ options?: APIApplicationCommandOption[];
116
+ default_member_permissions: import("discord.js").Permissions | null;
117
+ dm_permission?: boolean;
118
+ default_permission?: boolean;
119
+ nsfw?: boolean;
120
+ integration_types?: import("discord.js").ApplicationIntegrationType[];
121
+ contexts?: import("discord.js").InteractionContextType[] | null;
122
+ version: import("discord.js").Snowflake;
123
+ handler?: import("discord.js").EntryPointCommandHandlerType;
124
+ })[];
50
125
  changed: {
51
- local: SlashCommandRuntime;
52
- remote: APIApplicationCommand;
126
+ local: SlashCommandRuntime | SlashCommandSubcommandRuntime | SlashCommandSubcommandGroupRuntime;
127
+ remote: {
128
+ name: string;
129
+ subcommands: never[];
130
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
131
+ type: ApplicationCommandOptionType.Subcommand;
132
+ name_localizations?: import("discord.js").LocalizationMap | null;
133
+ description: string;
134
+ description_localizations?: import("discord.js").LocalizationMap | null;
135
+ required?: boolean;
136
+ } | {
137
+ name: string;
138
+ subcommands: {
139
+ name: string;
140
+ subcommands: never[];
141
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
142
+ type: ApplicationCommandOptionType.Subcommand;
143
+ name_localizations?: import("discord.js").LocalizationMap | null;
144
+ description: string;
145
+ description_localizations?: import("discord.js").LocalizationMap | null;
146
+ required?: boolean;
147
+ }[];
148
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
149
+ type: ApplicationCommandOptionType.SubcommandGroup;
150
+ name_localizations?: import("discord.js").LocalizationMap | null;
151
+ description: string;
152
+ description_localizations?: import("discord.js").LocalizationMap | null;
153
+ required?: boolean;
154
+ } | {
155
+ subcommands: ({
156
+ name: string;
157
+ subcommands: never[];
158
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
159
+ type: ApplicationCommandOptionType.Subcommand;
160
+ name_localizations?: import("discord.js").LocalizationMap | null;
161
+ description: string;
162
+ description_localizations?: import("discord.js").LocalizationMap | null;
163
+ required?: boolean;
164
+ } | {
165
+ name: string;
166
+ subcommands: {
167
+ name: string;
168
+ subcommands: never[];
169
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
170
+ type: ApplicationCommandOptionType.Subcommand;
171
+ name_localizations?: import("discord.js").LocalizationMap | null;
172
+ description: string;
173
+ description_localizations?: import("discord.js").LocalizationMap | null;
174
+ required?: boolean;
175
+ }[];
176
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
177
+ type: ApplicationCommandOptionType.SubcommandGroup;
178
+ name_localizations?: import("discord.js").LocalizationMap | null;
179
+ description: string;
180
+ description_localizations?: import("discord.js").LocalizationMap | null;
181
+ required?: boolean;
182
+ })[];
183
+ id: import("discord.js").Snowflake;
184
+ type: import("discord.js").ApplicationCommandType;
185
+ application_id: import("discord.js").Snowflake;
186
+ guild_id?: import("discord.js").Snowflake;
187
+ name: string;
188
+ name_localizations?: import("discord.js").LocalizationMap | null;
189
+ name_localized?: string;
190
+ description: string;
191
+ description_localizations?: import("discord.js").LocalizationMap | null;
192
+ description_localized?: string;
193
+ options?: APIApplicationCommandOption[];
194
+ default_member_permissions: import("discord.js").Permissions | null;
195
+ dm_permission?: boolean;
196
+ default_permission?: boolean;
197
+ nsfw?: boolean;
198
+ integration_types?: import("discord.js").ApplicationIntegrationType[];
199
+ contexts?: import("discord.js").InteractionContextType[] | null;
200
+ version: import("discord.js").Snowflake;
201
+ handler?: import("discord.js").EntryPointCommandHandlerType;
202
+ };
53
203
  }[];
54
204
  synced: {
55
- local: SlashCommandRuntime;
56
- remote: APIApplicationCommand;
205
+ local: SlashCommandRuntime | SlashCommandSubcommandRuntime | SlashCommandSubcommandGroupRuntime;
206
+ remote: {
207
+ name: string;
208
+ subcommands: never[];
209
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
210
+ type: ApplicationCommandOptionType.Subcommand;
211
+ name_localizations?: import("discord.js").LocalizationMap | null;
212
+ description: string;
213
+ description_localizations?: import("discord.js").LocalizationMap | null;
214
+ required?: boolean;
215
+ } | {
216
+ name: string;
217
+ subcommands: {
218
+ name: string;
219
+ subcommands: never[];
220
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
221
+ type: ApplicationCommandOptionType.Subcommand;
222
+ name_localizations?: import("discord.js").LocalizationMap | null;
223
+ description: string;
224
+ description_localizations?: import("discord.js").LocalizationMap | null;
225
+ required?: boolean;
226
+ }[];
227
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
228
+ type: ApplicationCommandOptionType.SubcommandGroup;
229
+ name_localizations?: import("discord.js").LocalizationMap | null;
230
+ description: string;
231
+ description_localizations?: import("discord.js").LocalizationMap | null;
232
+ required?: boolean;
233
+ } | {
234
+ subcommands: ({
235
+ name: string;
236
+ subcommands: never[];
237
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
238
+ type: ApplicationCommandOptionType.Subcommand;
239
+ name_localizations?: import("discord.js").LocalizationMap | null;
240
+ description: string;
241
+ description_localizations?: import("discord.js").LocalizationMap | null;
242
+ required?: boolean;
243
+ } | {
244
+ name: string;
245
+ subcommands: {
246
+ name: string;
247
+ subcommands: never[];
248
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
249
+ type: ApplicationCommandOptionType.Subcommand;
250
+ name_localizations?: import("discord.js").LocalizationMap | null;
251
+ description: string;
252
+ description_localizations?: import("discord.js").LocalizationMap | null;
253
+ required?: boolean;
254
+ }[];
255
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
256
+ type: ApplicationCommandOptionType.SubcommandGroup;
257
+ name_localizations?: import("discord.js").LocalizationMap | null;
258
+ description: string;
259
+ description_localizations?: import("discord.js").LocalizationMap | null;
260
+ required?: boolean;
261
+ })[];
262
+ id: import("discord.js").Snowflake;
263
+ type: import("discord.js").ApplicationCommandType;
264
+ application_id: import("discord.js").Snowflake;
265
+ guild_id?: import("discord.js").Snowflake;
266
+ name: string;
267
+ name_localizations?: import("discord.js").LocalizationMap | null;
268
+ name_localized?: string;
269
+ description: string;
270
+ description_localizations?: import("discord.js").LocalizationMap | null;
271
+ description_localized?: string;
272
+ options?: APIApplicationCommandOption[];
273
+ default_member_permissions: import("discord.js").Permissions | null;
274
+ dm_permission?: boolean;
275
+ default_permission?: boolean;
276
+ nsfw?: boolean;
277
+ integration_types?: import("discord.js").ApplicationIntegrationType[];
278
+ contexts?: import("discord.js").InteractionContextType[] | null;
279
+ version: import("discord.js").Snowflake;
280
+ handler?: import("discord.js").EntryPointCommandHandlerType;
281
+ };
57
282
  }[];
58
- conflict: SlashCommandRuntime[];
283
+ conflict: (SlashCommandRuntime | SlashCommandSubcommandRuntime | SlashCommandSubcommandGroupRuntime)[];
59
284
  }>;
60
- registerSlashCommands(): Promise<RESTPutAPIApplicationCommandsResult | PromiseSettledResult<APIApplicationCommand>[]>;
285
+ registerSlashCommands(): Promise<RESTPutAPIApplicationCommandsResult | PromiseSettledResult<import("discord.js").APIApplicationCommand>[]>;
61
286
  }
62
287
  export declare function isPromise(value: any): value is Promise<unknown>;
@@ -1,5 +1,5 @@
1
1
  import process from "node:process";
2
- import { ApplicationCommandOptionType, Events, Client as InternalClient, REST, Routes, SlashCommandBuilder } from "discord.js";
2
+ import { ApplicationCommandOptionType, Events, Client as InternalClient, REST, Routes, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from "discord.js";
3
3
  import { useNitroApp } from "nitropack/runtime";
4
4
  import { effectScope, isRef } from "vue";
5
5
  import { logger } from "../../logger.js";
@@ -53,7 +53,27 @@ export class DiscordClient {
53
53
  return;
54
54
  }
55
55
  const commandName = interaction.commandName;
56
- const command = this.#slashCommands.find((cmd) => cmd.name === commandName);
56
+ let command = this.#slashCommands.find((cmd) => cmd.name === commandName);
57
+ if (!command) {
58
+ logger.warn(`Unknown slash command: ${commandName}`);
59
+ this.#nitro.hooks.callHook("discord:client:error", {
60
+ type: "UnknownSlashCommandError",
61
+ client: this,
62
+ interaction
63
+ });
64
+ return;
65
+ }
66
+ if (command.subcommands != null && (command.subcommands?.length ?? 0) > 0) {
67
+ const group = interaction.options.getSubcommandGroup(false);
68
+ const subcommand = interaction.options.getSubcommand(false);
69
+ if (group && subcommand) {
70
+ command = command.subcommands.find((subcmd) => subcmd.name === group)?.subcommands?.find((subcmd) => subcmd.name === subcommand);
71
+ } else if (subcommand) {
72
+ command = command.subcommands.find((subcmd) => subcmd.name === subcommand);
73
+ } else {
74
+ logger.warn(`Unknown slash command subcommand: ${commandName} ${group ?? ""} ${subcommand}`);
75
+ }
76
+ }
57
77
  if (!command) {
58
78
  logger.warn(`Unknown slash command: ${commandName}`);
59
79
  this.#nitro.hooks.callHook("discord:client:error", {
@@ -266,67 +286,84 @@ export class DiscordClient {
266
286
  const choices = await autocompleteFunction(focusedOption.value, interaction);
267
287
  await interaction.respond(choices);
268
288
  }
269
- #getSlashCommandBuilder(command) {
270
- const builder = new SlashCommandBuilder().setName(command.name).setDescription(command.description);
271
- for (const option of command.options) {
272
- switch (option.type) {
273
- case ApplicationCommandOptionType.String:
274
- builder.addStringOption((opt) => {
275
- opt.setName(option.name).setRequired(option.required);
276
- if (option.description.length > 0)
277
- opt = opt.setDescription(option.description);
278
- if (option.minLength)
279
- opt = opt.setMinLength(option.minLength);
280
- if (option.maxLength)
281
- opt = opt.setMaxLength(option.maxLength);
282
- if (option.choices)
283
- opt = opt.addChoices(...option.choices);
284
- if (option.hasAutocomplete) {
285
- opt = opt.setAutocomplete(true);
286
- }
287
- return opt;
288
- });
289
- break;
290
- case ApplicationCommandOptionType.Integer:
291
- builder.addIntegerOption((opt) => {
292
- opt.setName(option.name).setRequired(option.required);
293
- if (option.description.length > 0)
294
- opt = opt.setDescription(option.description);
295
- if (option.min)
296
- opt = opt.setMinValue(option.min);
297
- if (option.max)
298
- opt = opt.setMaxValue(option.max);
299
- if (option.choices)
300
- opt = opt.addChoices(...option.choices);
301
- if (option.hasAutocomplete)
302
- opt = opt.setAutocomplete(true);
303
- return opt;
304
- });
305
- break;
306
- case ApplicationCommandOptionType.Number:
307
- builder.addNumberOption((opt) => {
308
- opt.setName(option.name).setRequired(option.required);
309
- if (option.description.length > 0)
310
- opt = opt.setDescription(option.description);
311
- if (option.min)
312
- opt = opt.setMinValue(option.min);
313
- if (option.max)
314
- opt = opt.setMaxValue(option.max);
315
- if (option.choices)
316
- opt = opt.addChoices(...option.choices);
317
- if (option.hasAutocomplete)
318
- opt = opt.setAutocomplete(true);
319
- return opt;
320
- });
321
- break;
322
- case ApplicationCommandOptionType.Boolean:
323
- builder.addBooleanOption((opt) => {
324
- opt.setName(option.name).setRequired(option.required);
325
- if (option.description.length > 0)
326
- opt = opt.setDescription(option.description);
327
- return opt;
328
- });
329
- break;
289
+ #getSlashCommandBuilder(command, builder) {
290
+ builder ??= new SlashCommandBuilder();
291
+ builder.setName(command.name).setDescription(command.description);
292
+ if (command.subcommands != null && command.subcommands.length > 0) {
293
+ for (const subcommand of command.subcommands) {
294
+ if (builder instanceof SlashCommandBuilder) {
295
+ if ("subcommands" in subcommand && (subcommand.subcommands?.length ?? 0) > 0) {
296
+ builder.addSubcommandGroup((subcommandGroupBuilder) => this.#getSlashCommandBuilder(subcommand, subcommandGroupBuilder));
297
+ } else {
298
+ builder.addSubcommand((subcommandBuilder) => this.#getSlashCommandBuilder(subcommand, subcommandBuilder));
299
+ }
300
+ } else if (builder instanceof SlashCommandSubcommandGroupBuilder) {
301
+ builder.addSubcommand((subcommandBuilder) => this.#getSlashCommandBuilder(subcommand, subcommandBuilder));
302
+ } else {
303
+ throw new TypeError(`Unexpected builder type: ${builder.constructor.name}`);
304
+ }
305
+ }
306
+ } else if (builder instanceof SlashCommandBuilder || builder instanceof SlashCommandSubcommandBuilder) {
307
+ for (const option of command.options) {
308
+ switch (option.type) {
309
+ case ApplicationCommandOptionType.String:
310
+ builder.addStringOption((opt) => {
311
+ opt.setName(option.name).setRequired(option.required);
312
+ if (option.description.length > 0)
313
+ opt = opt.setDescription(option.description);
314
+ if (option.minLength)
315
+ opt = opt.setMinLength(option.minLength);
316
+ if (option.maxLength)
317
+ opt = opt.setMaxLength(option.maxLength);
318
+ if (option.choices)
319
+ opt = opt.addChoices(...option.choices);
320
+ if (option.hasAutocomplete) {
321
+ opt = opt.setAutocomplete(true);
322
+ }
323
+ return opt;
324
+ });
325
+ break;
326
+ case ApplicationCommandOptionType.Integer:
327
+ builder.addIntegerOption((opt) => {
328
+ opt.setName(option.name).setRequired(option.required);
329
+ if (option.description.length > 0)
330
+ opt = opt.setDescription(option.description);
331
+ if (option.min)
332
+ opt = opt.setMinValue(option.min);
333
+ if (option.max)
334
+ opt = opt.setMaxValue(option.max);
335
+ if (option.choices)
336
+ opt = opt.addChoices(...option.choices);
337
+ if (option.hasAutocomplete)
338
+ opt = opt.setAutocomplete(true);
339
+ return opt;
340
+ });
341
+ break;
342
+ case ApplicationCommandOptionType.Number:
343
+ builder.addNumberOption((opt) => {
344
+ opt.setName(option.name).setRequired(option.required);
345
+ if (option.description.length > 0)
346
+ opt = opt.setDescription(option.description);
347
+ if (option.min)
348
+ opt = opt.setMinValue(option.min);
349
+ if (option.max)
350
+ opt = opt.setMaxValue(option.max);
351
+ if (option.choices)
352
+ opt = opt.addChoices(...option.choices);
353
+ if (option.hasAutocomplete)
354
+ opt = opt.setAutocomplete(true);
355
+ return opt;
356
+ });
357
+ break;
358
+ case ApplicationCommandOptionType.Boolean:
359
+ builder.addBooleanOption((opt) => {
360
+ opt.setName(option.name).setRequired(option.required);
361
+ if (option.description.length > 0)
362
+ opt = opt.setDescription(option.description);
363
+ return opt;
364
+ });
365
+ break;
366
+ }
330
367
  }
331
368
  }
332
369
  return builder;
@@ -341,23 +378,61 @@ export class DiscordClient {
341
378
  await this.getRemoteSlashCommands();
342
379
  }
343
380
  const remoteCommands = this.#cachedRemoteSlashCommands;
344
- const nameToCommands = localCommands.reduce((acc, command) => {
381
+ const flattenedRemoteCommands = remoteCommands.flatMap((cmd) => {
382
+ const subcommands = cmd.options?.flatMap((option) => {
383
+ const name = `${cmd.name} ${option.name}`;
384
+ if (option.type === ApplicationCommandOptionType.Subcommand) {
385
+ return [{ ...option, name, subcommands: [] }];
386
+ } else if (option.type === ApplicationCommandOptionType.SubcommandGroup) {
387
+ const subcommands2 = option.options?.flatMap((suboption) => {
388
+ return suboption.type === ApplicationCommandOptionType.Subcommand ? [{ ...suboption, name: `${name} ${suboption.name}`, subcommands: [] }] : [];
389
+ }) ?? [];
390
+ return [
391
+ { ...option, name, subcommands: subcommands2 },
392
+ ...subcommands2
393
+ ];
394
+ }
395
+ return [];
396
+ }) ?? [];
397
+ return [
398
+ { ...cmd, subcommands },
399
+ ...subcommands
400
+ ];
401
+ });
402
+ const flattenedLocalCommands = localCommands.flatMap(
403
+ (cmd) => [
404
+ cmd,
405
+ ...cmd.subcommands?.flatMap((subcmd) => {
406
+ const name = `${cmd.name} ${subcmd.name}`;
407
+ return [
408
+ { ...subcmd, name },
409
+ ...subcmd.subcommands?.map((subsubcmd) => ({ ...subsubcmd, name: `${name} ${subsubcmd.name}` })) ?? []
410
+ ];
411
+ }) ?? []
412
+ ]
413
+ );
414
+ const nameToCommands = flattenedLocalCommands.reduce((acc, command) => {
345
415
  (acc[command.name] ??= []).push(command);
346
416
  return acc;
347
417
  }, {});
348
- return localCommands.reduce((acc, command) => {
349
- const remoteCommand = remoteCommands.find((cmd) => cmd.name === command.name);
418
+ return flattenedLocalCommands.reduce((acc, command) => {
350
419
  if (nameToCommands[command.name].length > 1) {
351
420
  acc.conflict.push(command);
352
- } else if (!remoteCommand) {
421
+ return acc;
422
+ }
423
+ const remoteCommand = flattenedRemoteCommands.find((cmd) => cmd.name === command.name);
424
+ if (!remoteCommand) {
353
425
  acc.added.push(command);
354
- } else if (!propsEqual(command, remoteCommand, [
355
- "description"
356
- /* TODO: more */
357
- ]) || (command.options?.length ?? 0) !== (remoteCommand.options?.length ?? 0) || (remoteCommand.options ?? []).some((opt, i) => !optionEqual(command.options[i], opt))) {
426
+ } else if (
427
+ // if some properties are different
428
+ !propsEqual(command, remoteCommand, [
429
+ "description"
430
+ /* TODO: more */
431
+ ]) || !((command.subcommands?.length ?? 0) > 0 && remoteCommand.subcommands.length > 0) && ((command.options?.length ?? 0) !== (remoteCommand.options?.length ?? 0) || (remoteCommand.options ?? []).some((opt, i) => !optionEqual(command.options[i], opt)))
432
+ ) {
358
433
  acc.changed.push({ local: command, remote: remoteCommand });
359
434
  } else {
360
- if (remoteCommand.id && !command.id) {
435
+ if ("id" in remoteCommand && !command.id) {
361
436
  command.id = remoteCommand.id;
362
437
  }
363
438
  acc.synced.push({ local: command, remote: remoteCommand });
@@ -365,7 +440,7 @@ export class DiscordClient {
365
440
  return acc;
366
441
  }, {
367
442
  added: [],
368
- removed: remoteCommands.filter(({ name }) => !localCommands.some((cmd) => cmd.name === name)),
443
+ removed: flattenedRemoteCommands.filter(({ name }) => !(name in nameToCommands)),
369
444
  changed: [],
370
445
  synced: [],
371
446
  conflict: []
@@ -378,7 +453,7 @@ export class DiscordClient {
378
453
  return [];
379
454
  }
380
455
  this.#cachedRemoteSlashCommands = null;
381
- if (diff.added.length > 0 || diff.removed.length > 0 || diff.changed.length > 2) {
456
+ if (true) {
382
457
  try {
383
458
  const result = await this.#rest.put(
384
459
  Routes.applicationCommands(this.#clientId),
@@ -402,6 +477,8 @@ export class DiscordClient {
402
477
  } else {
403
478
  const results = await Promise.allSettled(
404
479
  diff.changed.map((command) => {
480
+ if (!("id" in command.remote))
481
+ return Promise.reject(new Error(`Remote command ${command.local.name} does not have an ID`));
405
482
  logger.log(`Updating slash command: ${command.local.name}`);
406
483
  const builder = this.#getSlashCommandBuilder(command.local);
407
484
  return this.#rest.patch(
@@ -32,4 +32,5 @@ type ReplyFunction = SlashCommandCustomReturnHandler & {
32
32
  send: ReplyFunction;
33
33
  };
34
34
  export declare const reply: ReplyFunction;
35
+ export declare function deepToRaw<T extends Record<string, any>>(sourceObj: T): T;
35
36
  export {};