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.
package/README.md CHANGED
@@ -252,11 +252,11 @@ Here's what's planned for future releases:
252
252
  - [ ] Attachment type
253
253
  - [ ] Better JSDocs support JSDoc comments
254
254
  - [ ] Localization support
255
- - [ ] File-based subcommands
255
+ - [x] File-based subcommands
256
256
  - [x] Auto-complete API
257
257
  - [ ] Guild-specific commands
258
258
  - [ ] Nuxt-devtools integration
259
- - [ ] Unit tests
259
+ - [ ] Unit tests (WIP)
260
260
 
261
261
  ### Web Interface Enhancements
262
262
 
package/dist/module.d.mts CHANGED
@@ -117,13 +117,32 @@ interface SlashCommand {
117
117
  options: (SlashCommandOption & {
118
118
  varname: string;
119
119
  })[];
120
+ parents: [];
121
+ subcommands: (SlashCommandSubcommand | SlashCommandSubcommandGroup)[];
120
122
  }
121
- interface SlashCommandRuntime extends SlashCommand {
123
+ interface SlashCommandSubcommandGroup extends Omit<SlashCommand, 'subcommands' | 'parents'> {
124
+ parents: [string];
125
+ subcommands: SlashCommandSubcommand[];
126
+ }
127
+ interface SlashCommandSubcommand extends Omit<SlashCommand, 'subcommands' | 'parents'> {
128
+ parents: [string] | [string, string];
129
+ subcommands: [];
130
+ }
131
+ interface SlashCommandRuntime extends Omit<SlashCommand, 'subcommands'> {
122
132
  /** if execute is not defined load must be defined */
123
133
  load?: () => Promise<Pick<SlashCommandRuntime, 'execute' | 'optionMacros'>>;
124
134
  execute?: (...args: (SlashCommandOptionType | undefined)[]) => SlashCommandReturnType;
125
135
  id?: string;
126
136
  optionMacros?: Record<string, DescribeOptionOptions>;
137
+ subcommands?: (SlashCommandSubcommandRuntime | SlashCommandSubcommandGroupRuntime)[];
138
+ }
139
+ interface SlashCommandSubcommandGroupRuntime extends Omit<SlashCommandRuntime, 'subcommands' | 'parents'> {
140
+ parents: [string];
141
+ subcommands?: SlashCommandSubcommandRuntime[];
142
+ }
143
+ interface SlashCommandSubcommandRuntime extends Omit<SlashCommandRuntime, 'subcommands' | 'parents'> {
144
+ parents: [string] | [string, string];
145
+ subcommands?: [];
127
146
  }
128
147
  interface NuxtDiscordContext {
129
148
  nuxt: nuxt_schema.Nuxt;
@@ -139,4 +158,4 @@ interface NuxtDiscordContext {
139
158
  declare const _default: _nuxt_schema.NuxtModule<NuxtDiscordOptions, NuxtDiscordOptions, false>;
140
159
 
141
160
  export { _default as default, slashCommandOptionTypeIdentifiers, typeIdentifierToEnum };
142
- export type { DiscordRuntimeConfig, NuxtDiscordContext, NuxtDiscordOptions, SlashCommand, SlashCommandBooleanOption, SlashCommandCustomReturnHandler, SlashCommandIntegerOption, SlashCommandNumberOption, SlashCommandOption, SlashCommandOptionBase, SlashCommandOptionType, SlashCommandOptionTypeIdentifier, SlashCommandReturnType, SlashCommandRuntime, SlashCommandStringOption, integer };
161
+ export type { DiscordRuntimeConfig, NuxtDiscordContext, NuxtDiscordOptions, SlashCommand, SlashCommandBooleanOption, SlashCommandCustomReturnHandler, SlashCommandIntegerOption, SlashCommandNumberOption, SlashCommandOption, SlashCommandOptionBase, SlashCommandOptionType, SlashCommandOptionTypeIdentifier, SlashCommandReturnType, SlashCommandRuntime, SlashCommandStringOption, SlashCommandSubcommand, SlashCommandSubcommandGroup, SlashCommandSubcommandGroupRuntime, SlashCommandSubcommandRuntime, integer };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-discord",
3
3
  "configKey": "discord",
4
- "version": "0.0.15",
4
+ "version": "0.0.17",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "3.5.0"
package/dist/module.mjs CHANGED
@@ -158,6 +158,7 @@ function collectSlashCommands(ctx) {
158
158
  ctx.slashCommands.push(command);
159
159
  }
160
160
  }
161
+ processSubcommands(ctx);
161
162
  }
162
163
  function processCommandFile(ctx, file) {
163
164
  const sourceFile = ts.createSourceFile(
@@ -176,6 +177,7 @@ function processCommandFile(ctx, file) {
176
177
  const command = {
177
178
  path: file,
178
179
  options: [],
180
+ subcommands: [],
179
181
  name
180
182
  };
181
183
  if ((ts.isFunctionDeclaration(commandDefinition) || ts.isFunctionExpression(commandDefinition)) && !!commandDefinition.name && ts.isIdentifier(commandDefinition.name) && commandDefinition.name.escapedText) {
@@ -298,8 +300,56 @@ function processCommandFile(ctx, file) {
298
300
  if (outOfRangMacroCalls.length > 0) {
299
301
  ctx.logger.warn(`Macros in file ${file} must be called at the top of the file`);
300
302
  }
303
+ const commandsDir = ctx.resolve.root(ctx.options.dir, "commands");
304
+ const parents = path.relative(commandsDir, file).split(path.sep).slice(0, -1);
305
+ if (parents.length > 2) {
306
+ ctx.logger.warn(`Only 2 levels of subcommand nesting are supported, see https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups`);
307
+ return;
308
+ } else if (parents.length === 1) {
309
+ command.parents = [
310
+ path.resolve(commandsDir, `${parents[0]}.ts`)
311
+ ];
312
+ } else if (parents.length === 2) {
313
+ command.parents = [
314
+ path.resolve(commandsDir, `${parents[0]}.ts`),
315
+ path.resolve(commandsDir, parents[0], `${parents[1]}.ts`)
316
+ ];
317
+ } else {
318
+ command.parents = [];
319
+ }
301
320
  return command;
302
321
  }
322
+ function processSubcommands(ctx) {
323
+ for (let i = 0; i < 2; i++) {
324
+ const done = [];
325
+ ctx.slashCommands.forEach((command, i2) => {
326
+ if (command.parents.length > 0) {
327
+ const rootCommand = ctx.slashCommands.find((c) => c.path === command.parents[0]);
328
+ if (rootCommand) {
329
+ if (command.parents.length === 1) {
330
+ done.unshift(i2);
331
+ rootCommand.subcommands.push(command);
332
+ } else {
333
+ const subcommandGroup = rootCommand.subcommands.find(
334
+ (c) => c.path === command.parents[1]
335
+ );
336
+ if (subcommandGroup) {
337
+ done.unshift(i2);
338
+ subcommandGroup.subcommands.push(command);
339
+ }
340
+ }
341
+ }
342
+ }
343
+ });
344
+ done.forEach((i2) => ctx.slashCommands.splice(i2, 1));
345
+ }
346
+ const notProcessed = ctx.slashCommands.filter((c) => c.parents.length > 0);
347
+ for (const command of notProcessed) {
348
+ ctx.logger.warn(`Slash command ${command.name} is not processed, please create dummy parent command files:
349
+ ${command.parents.map((p) => ` - ${p}`).join("\n")}`);
350
+ }
351
+ ctx.slashCommands = ctx.slashCommands.filter((c) => c.parents.length === 0);
352
+ }
303
353
  function extractCommandDefinition(sourceFile) {
304
354
  let commandDefinition;
305
355
  ts.forEachChild(sourceFile, (node) => {
@@ -642,8 +692,9 @@ async function generateDynamicCommandBuild(file, config, ctx) {
642
692
  ]
643
693
  });
644
694
  const { output } = await bundle.generate({ ...config.output, sourcemap: false });
645
- fs.mkdirSync(path.join(ctx.nuxt.options.buildDir, "discord", "commands"), { recursive: true });
646
- fs.writeFileSync(file.replace(ctx.resolve.root(ctx.nuxt.options.rootDir), ctx.nuxt.options.buildDir).replace(".ts", ".mjs"), output[0].code, { encoding: "utf-8", flush: true });
695
+ const outputFilePath = file.replace(ctx.resolve.root(ctx.nuxt.options.rootDir), ctx.nuxt.options.buildDir).replace(".ts", ".mjs");
696
+ fs.mkdirSync(path.dirname(outputFilePath), { recursive: true });
697
+ fs.writeFileSync(outputFilePath, output[0].code, { encoding: "utf-8", flush: true });
647
698
  } catch (error) {
648
699
  ctx.logger.error(`Error processing command file ${file}:`, error);
649
700
  return;
@@ -690,6 +741,11 @@ declare module 'discord/slashCommands' {
690
741
  export default slashCommands
691
742
  }
692
743
 
744
+ declare module '#build/discord/slashCommands' {
745
+ declare const slashCommands: import('nuxt-discord').SlashCommand[]
746
+ export default slashCommands
747
+ }
748
+
693
749
  type integer = import('nuxt-discord').integer
694
750
 
695
751
  declare global {
@@ -720,23 +776,33 @@ declare global {
720
776
  });
721
777
  }
722
778
  function getSlashCommandTemplateContent(ctx, commandRuntime) {
723
- const imports = commandRuntime ? ctx.slashCommands.map(({ path }) => {
724
- const name = genSafeVariableName(path);
725
- return { name, code: genImport(path, [{ name: "default", as: name }]) };
726
- }) : [];
779
+ const imports = commandRuntime ? Object.fromEntries(ctx.slashCommands.flatMap(
780
+ function getImports(cmd) {
781
+ const name = genSafeVariableName(cmd.path);
782
+ return [
783
+ [cmd.path, { name, code: genImport(cmd.path, [{ name: "default", as: name }]) }],
784
+ ..."subcommands" in cmd ? cmd.subcommands.flatMap(getImports) : []
785
+ ];
786
+ }
787
+ )) : {};
727
788
  return [
728
- ...imports.map(({ code }) => code),
789
+ ...Object.values(imports).map(({ code }) => code),
729
790
  `export default [
730
- ${ctx.slashCommands.map(({ options, ...rest }, i) => ` {
791
+ ${ctx.slashCommands.map((cmd) => genCommandObject(cmd)).join(",\n")}]`
792
+ ].join("\n");
793
+ function genCommandObject({
794
+ options,
795
+ parents,
796
+ subcommands,
797
+ ...rest
798
+ }) {
799
+ return ` {
731
800
  ${Object.entries(rest).map(([key, value]) => `${key}: ${genString(value)}`).join(",\n ")},
732
-
733
801
  options: ${genArrayFromRaw(options, void 0, { preserveTypes: true })},
734
- ${commandRuntime ? `
735
- ...${imports[i].name},
736
- ` : ""}
737
- },
738
- `).join("")}]`
739
- ].join("\n");
802
+ ${subcommands.length > 0 ? `subcommands: [${subcommands.map(genCommandObject).join(",")}],` : ""}
803
+ ${commandRuntime ? `...${imports[rest.path].name},` : ""}
804
+ }`;
805
+ }
740
806
  }
741
807
 
742
808
  const module = defineNuxtModule({
@@ -1 +1 @@
1
- @supports ((-webkit-hyphens:none) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--un-border-opacity:100%;--un-divide-opacity:100%;--un-text-opacity:100%;--un-space-y-reverse:initial}}@property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-inset-ring-color{syntax:"*";inherits:false}@property --un-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow-color{syntax:"*";inherits:false}@property --un-ring-color{syntax:"*";inherits:false}@property --un-ring-inset{syntax:"*";inherits:false}@property --un-ring-offset-color{syntax:"*";inherits:false}@property --un-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --un-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow-color{syntax:"*";inherits:false}@property --un-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --un-divide-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}:host,:root{--spacing:0.25rem;--fontWeight-bold:700;--default-transition-timingFunction:cubic-bezier(0.4,0,0.2,1);--default-transition-duration:150ms;--fontWeight-semibold:600;--fontWeight-medium:500;--colors-gray-900:oklch(21% 0.034 264.665);--colors-gray-600:oklch(44.6% 0.03 256.802);--colors-gray-700:oklch(37.3% 0.034 259.733);--colors-gray-500:oklch(55.1% 0.027 264.364);--colors-gray-400:oklch(70.7% 0.022 261.325);--text-3xl-fontSize:1.875rem;--text-3xl-lineHeight:2.25rem;--text-sm-fontSize:0.875rem;--text-sm-lineHeight:1.25rem;--text-lg-fontSize:1.125rem;--text-lg-lineHeight:1.75rem;--text-xs-fontSize:0.75rem;--text-xs-lineHeight:1rem;--text-2xl-fontSize:1.5rem;--text-2xl-lineHeight:2rem;--colors-white:#fff;--colors-gray-200:oklch(92.8% 0.006 264.531);--colors-gray-300:oklch(87.2% 0.01 258.338)}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.text-3xl{font-size:var(--text-3xl-fontSize);line-height:var(--un-leading,var(--text-3xl-lineHeight))}.text-lg{font-size:var(--text-lg-fontSize);line-height:var(--un-leading,var(--text-lg-lineHeight))}.text-sm{font-size:var(--text-sm-fontSize);line-height:var(--un-leading,var(--text-sm-lineHeight))}.text-xs{font-size:var(--text-xs-fontSize);line-height:var(--un-leading,var(--text-xs-lineHeight))}.dark .dark\:text-gray-200{color:color-mix(in srgb,var(--colors-gray-200) var(--un-text-opacity),transparent)}.dark .dark\:text-gray-300{color:color-mix(in srgb,var(--colors-gray-300) var(--un-text-opacity),transparent)}.dark .dark\:text-gray-400,.text-gray-400{color:color-mix(in srgb,var(--colors-gray-400) var(--un-text-opacity),transparent)}.dark .dark\:text-white{color:color-mix(in srgb,var(--colors-white) var(--un-text-opacity),transparent)}.text-\[var\(--ui-error\)\]\!{color:color-mix(in oklab,var(--ui-error) var(--un-text-opacity),transparent)!important}.text-gray-500{color:color-mix(in srgb,var(--colors-gray-500) var(--un-text-opacity),transparent)}.text-gray-600{color:color-mix(in srgb,var(--colors-gray-600) var(--un-text-opacity),transparent)}.text-gray-700{color:color-mix(in srgb,var(--colors-gray-700) var(--un-text-opacity),transparent)}.text-gray-900{color:color-mix(in srgb,var(--colors-gray-900) var(--un-text-opacity),transparent)}.font-bold{--un-font-weight:var(--fontWeight-bold);font-weight:var(--fontWeight-bold)}.font-medium{--un-font-weight:var(--fontWeight-medium);font-weight:var(--fontWeight-medium)}.font-semibold{--un-font-weight:var(--fontWeight-semibold);font-weight:var(--fontWeight-semibold)}.mx-auto{margin-inline:auto}.my-6{margin-block:calc(var(--spacing)*6)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-16{margin-bottom:calc(var(--spacing)*16)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mt-4{margin-top:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-12{padding-block:calc(var(--spacing)*12)}.pt-2{padding-top:calc(var(--spacing)*2)}.text-center{text-align:center}.outline{outline-style:var(--un-outline-style);outline-width:1px}.border{border-width:1px}.border-\[var\(--ui-error\)\]\/50,.divide-\[var\(--ui-error\)\]\/50>:not(:last-child){border-color:color-mix(in oklab,var(--ui-error) 50%,transparent)}.border-\[var\(--ui-neutral\)\]\/50,.divide-\[var\(--ui-neutral\)\]\/50>:not(:last-child){border-color:color-mix(in oklab,var(--ui-neutral) 50%,transparent)}.border-\[var\(--ui-secondary\)\]\/50,.divide-\[var\(--ui-secondary\)\]\/50>:not(:last-child){border-color:color-mix(in oklab,var(--ui-secondary) 50%,transparent)}.border-\[var\(--ui-warning\)\]\/50,.divide-\[var\(--ui-warning\)\]\/50>:not(:last-child){border-color:color-mix(in oklab,var(--ui-warning) 50%,transparent)}.border-dashed{--un-border-style:dashed;border-style:dashed}.flex{display:flex}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.grid{display:grid}.h-12{height:calc(var(--spacing)*12)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.w-12{width:calc(var(--spacing)*12)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-full{width:100%}.hover\:cursor-pointer:hover{cursor:pointer}.disabled\:hover\:cursor-not-allowed:hover:disabled{cursor:not-allowed}.ring-0{--un-ring-shadow:var(--un-ring-inset,) 0 0 0 calc(var(--un-ring-offset-width)) var(--un-ring-color,currentColor);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.transition-shadow{transition-duration:var(--un-duration,var(--default-transition-duration));transition-property:box-shadow;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction))}.duration-200{--un-duration:200ms;transition-duration:.2s}.items-center{align-items:center}.justify-between{justify-content:space-between}.overflow-hidden{overflow:hidden}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.space-y-1>:not(:last-child){--un-space-y-reverse:0;margin-block-end:calc(var(--spacing)*1*(1 - var(--un-space-y-reverse)));margin-block-start:calc(var(--spacing)*1*var(--un-space-y-reverse))}.divide-dashed>:not(:last-child){border-style:dashed}@supports (color:color-mix(in lab,red,red)){.dark .dark\:text-gray-200{color:color-mix(in oklab,var(--colors-gray-200) var(--un-text-opacity),transparent)}.dark .dark\:text-gray-300{color:color-mix(in oklab,var(--colors-gray-300) var(--un-text-opacity),transparent)}.dark .dark\:text-gray-400{color:color-mix(in oklab,var(--colors-gray-400) var(--un-text-opacity),transparent)}.dark .dark\:text-white{color:color-mix(in oklab,var(--colors-white) var(--un-text-opacity),transparent)}.text-gray-400{color:color-mix(in oklab,var(--colors-gray-400) var(--un-text-opacity),transparent)}.text-gray-500{color:color-mix(in oklab,var(--colors-gray-500) var(--un-text-opacity),transparent)}.text-gray-600{color:color-mix(in oklab,var(--colors-gray-600) var(--un-text-opacity),transparent)}.text-gray-700{color:color-mix(in oklab,var(--colors-gray-700) var(--un-text-opacity),transparent)}.text-gray-900{color:color-mix(in oklab,var(--colors-gray-900) var(--un-text-opacity),transparent)}}@media (min-width:40rem){.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:64rem){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}
1
+ @supports ((-webkit-hyphens:none) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--un-border-opacity:100%;--un-divide-opacity:100%;--un-text-opacity:100%;--un-space-y-reverse:initial}}@property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-inset-ring-color{syntax:"*";inherits:false}@property --un-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow-color{syntax:"*";inherits:false}@property --un-ring-color{syntax:"*";inherits:false}@property --un-ring-inset{syntax:"*";inherits:false}@property --un-ring-offset-color{syntax:"*";inherits:false}@property --un-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --un-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow-color{syntax:"*";inherits:false}@property --un-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --un-divide-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}:host,:root{--spacing:0.25rem;--fontWeight-bold:700;--default-transition-timingFunction:cubic-bezier(0.4,0,0.2,1);--default-transition-duration:150ms;--fontWeight-semibold:600;--fontWeight-medium:500;--colors-gray-900:oklch(21% 0.034 264.665);--colors-gray-600:oklch(44.6% 0.03 256.802);--colors-gray-700:oklch(37.3% 0.034 259.733);--colors-gray-500:oklch(55.1% 0.027 264.364);--colors-gray-400:oklch(70.7% 0.022 261.325);--text-3xl-fontSize:1.875rem;--text-3xl-lineHeight:2.25rem;--text-sm-fontSize:0.875rem;--text-sm-lineHeight:1.25rem;--text-lg-fontSize:1.125rem;--text-lg-lineHeight:1.75rem;--text-xs-fontSize:0.75rem;--text-xs-lineHeight:1rem;--text-2xl-fontSize:1.5rem;--text-2xl-lineHeight:2rem;--colors-white:#fff;--colors-gray-200:oklch(92.8% 0.006 264.531);--colors-gray-300:oklch(87.2% 0.01 258.338)}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.text-3xl{font-size:var(--text-3xl-fontSize);line-height:var(--un-leading,var(--text-3xl-lineHeight))}.text-lg{font-size:var(--text-lg-fontSize);line-height:var(--un-leading,var(--text-lg-lineHeight))}.text-sm{font-size:var(--text-sm-fontSize);line-height:var(--un-leading,var(--text-sm-lineHeight))}.text-xs{font-size:var(--text-xs-fontSize);line-height:var(--un-leading,var(--text-xs-lineHeight))}.dark .dark\:text-gray-200{color:color-mix(in srgb,var(--colors-gray-200) var(--un-text-opacity),transparent)}.dark .dark\:text-gray-300{color:color-mix(in srgb,var(--colors-gray-300) var(--un-text-opacity),transparent)}.dark .dark\:text-gray-400,.text-gray-400{color:color-mix(in srgb,var(--colors-gray-400) var(--un-text-opacity),transparent)}.dark .dark\:text-white{color:color-mix(in srgb,var(--colors-white) var(--un-text-opacity),transparent)}.text-\[var\(--ui-error\)\]\!{color:color-mix(in oklab,var(--ui-error) var(--un-text-opacity),transparent)!important}.text-gray-500{color:color-mix(in srgb,var(--colors-gray-500) var(--un-text-opacity),transparent)}.text-gray-600{color:color-mix(in srgb,var(--colors-gray-600) var(--un-text-opacity),transparent)}.text-gray-700{color:color-mix(in srgb,var(--colors-gray-700) var(--un-text-opacity),transparent)}.text-gray-900{color:color-mix(in srgb,var(--colors-gray-900) var(--un-text-opacity),transparent)}.font-bold{--un-font-weight:var(--fontWeight-bold);font-weight:var(--fontWeight-bold)}.font-medium{--un-font-weight:var(--fontWeight-medium);font-weight:var(--fontWeight-medium)}.font-semibold{--un-font-weight:var(--fontWeight-semibold);font-weight:var(--fontWeight-semibold)}.mx-auto{margin-inline:auto}.my-0\.75{margin-block:calc(var(--spacing)*.75)}.my-6{margin-block:calc(var(--spacing)*6)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-16{margin-bottom:calc(var(--spacing)*16)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mt-4{margin-top:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-12{padding-block:calc(var(--spacing)*12)}.pt-2{padding-top:calc(var(--spacing)*2)}.text-center{text-align:center}.outline{outline-style:var(--un-outline-style);outline-width:1px}.border{border-width:1px}.border-\[var\(--ui-error\)\]\/50,.divide-\[var\(--ui-error\)\]\/50>:not(:last-child){border-color:color-mix(in oklab,var(--ui-error) 50%,transparent)}.border-\[var\(--ui-neutral\)\]\/50,.divide-\[var\(--ui-neutral\)\]\/50>:not(:last-child){border-color:color-mix(in oklab,var(--ui-neutral) 50%,transparent)}.border-\[var\(--ui-secondary\)\]\/50,.divide-\[var\(--ui-secondary\)\]\/50>:not(:last-child){border-color:color-mix(in oklab,var(--ui-secondary) 50%,transparent)}.border-\[var\(--ui-warning\)\]\/50,.divide-\[var\(--ui-warning\)\]\/50>:not(:last-child){border-color:color-mix(in oklab,var(--ui-warning) 50%,transparent)}.border-dashed{--un-border-style:dashed;border-style:dashed}.flex{display:flex}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.grid{display:grid}.size-6{height:calc(var(--spacing)*6);width:calc(var(--spacing)*6)}.h-12{height:calc(var(--spacing)*12)}.h-4{height:calc(var(--spacing)*4)}.w-12{width:calc(var(--spacing)*12)}.w-4{width:calc(var(--spacing)*4)}.w-full{width:100%}.hover\:cursor-pointer:hover{cursor:pointer}.disabled\:hover\:cursor-not-allowed:hover:disabled{cursor:not-allowed}.ring-0{--un-ring-shadow:var(--un-ring-inset,) 0 0 0 calc(var(--un-ring-offset-width)) var(--un-ring-color,currentColor);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.transition-shadow{transition-duration:var(--un-duration,var(--default-transition-duration));transition-property:box-shadow;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction))}.duration-200{--un-duration:200ms;transition-duration:.2s}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-between{justify-content:space-between}.overflow-hidden{overflow:hidden}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.space-y-1>:not(:last-child){--un-space-y-reverse:0;margin-block-end:calc(var(--spacing)*1*(1 - var(--un-space-y-reverse)));margin-block-start:calc(var(--spacing)*1*var(--un-space-y-reverse))}.divide-dashed>:not(:last-child){border-style:dashed}@supports (color:color-mix(in lab,red,red)){.dark .dark\:text-gray-200{color:color-mix(in oklab,var(--colors-gray-200) var(--un-text-opacity),transparent)}.dark .dark\:text-gray-300{color:color-mix(in oklab,var(--colors-gray-300) var(--un-text-opacity),transparent)}.dark .dark\:text-gray-400{color:color-mix(in oklab,var(--colors-gray-400) var(--un-text-opacity),transparent)}.dark .dark\:text-white{color:color-mix(in oklab,var(--colors-white) var(--un-text-opacity),transparent)}.text-gray-400{color:color-mix(in oklab,var(--colors-gray-400) var(--un-text-opacity),transparent)}.text-gray-500{color:color-mix(in oklab,var(--colors-gray-500) var(--un-text-opacity),transparent)}.text-gray-600{color:color-mix(in oklab,var(--colors-gray-600) var(--un-text-opacity),transparent)}.text-gray-700{color:color-mix(in oklab,var(--colors-gray-700) var(--un-text-opacity),transparent)}.text-gray-900{color:color-mix(in oklab,var(--colors-gray-900) var(--un-text-opacity),transparent)}}@media (min-width:40rem){.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:64rem){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import slashCommands from "#build/discord/slashCommands";
2
3
  import { computed, ref, useFetch, useRuntimeConfig, watchEffect } from "#imports";
3
4
  import { useWebSocket } from "@vueuse/core";
4
5
  import TheHeader from "../components/TheHeader.vue";
@@ -69,7 +70,7 @@ function getRemoteId(command) {
69
70
  }
70
71
  return void 0;
71
72
  }
72
- const commands = ref([]);
73
+ const commands = ref(slashCommands);
73
74
  const {
74
75
  data: diff,
75
76
  refresh: refreshDiff
@@ -77,9 +78,6 @@ const {
77
78
  "/api/discord/slash-command/remote-diff",
78
79
  {
79
80
  method: "post",
80
- body: {
81
- commands
82
- },
83
81
  immediate: import.meta.dev
84
82
  }
85
83
  );
@@ -267,9 +265,9 @@ const statusClasses = {
267
265
  >
268
266
  <template #header>
269
267
  <div class="flex items-center justify-between">
270
- <div class="flex gap-3 items-center">
271
- <UIcon name="i-heroicons-command-line" class="text-primary-500 h-5 w-5" />
272
- <div>
268
+ <div class="flex gap-3 items-start">
269
+ <UIcon name="i-heroicons-command-line" class="text-primary-500 my-0.75 size-6" />
270
+ <div class="flex flex-col gap-1 items-start">
273
271
  <h3
274
272
  class="text-lg text-gray-700 font-semibold dark:text-gray-200"
275
273
  :class="command.status === 'conflict' && 'text-[var(--ui-error)]!'"
@@ -280,7 +278,14 @@ const statusClasses = {
280
278
  {{ command.description }}
281
279
  </p>
282
280
  <UBadge
283
- v-if="command.options.length > 0"
281
+ v-if="'subcommands' in command && (command.subcommands?.length ?? 0) > 0"
282
+ :label="`${command.subcommands.length} subcommand${command.subcommands.length === 1 ? '' : 's'}`"
283
+ variant="soft"
284
+ color="info"
285
+ size="sm"
286
+ />
287
+ <UBadge
288
+ v-else-if="command.options.length > 0"
284
289
  :label="`${command.options.length} option${command.options.length === 1 ? '' : 's'}`"
285
290
  variant="soft"
286
291
  color="neutral"
@@ -1,20 +1,239 @@
1
- import type { APIApplicationCommand } from 'discord.js';
2
- import type { SlashCommand, SlashCommandRuntime } from '../../../../../types.js';
3
- declare const _default: import("h3").EventHandler<{
4
- body?: {
5
- commands?: SlashCommand[];
6
- };
7
- }, Promise<{
8
- added: SlashCommandRuntime[];
9
- removed: APIApplicationCommand[];
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
2
+ added: (import("../../../../../types.js").SlashCommandRuntime | import("../../../../../types.js").SlashCommandSubcommandRuntime | import("../../../../../types.js").SlashCommandSubcommandGroupRuntime)[];
3
+ removed: ({
4
+ name: string;
5
+ subcommands: never[];
6
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
7
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
8
+ name_localizations?: import("discord.js").LocalizationMap | null;
9
+ description: string;
10
+ description_localizations?: import("discord.js").LocalizationMap | null;
11
+ required?: boolean;
12
+ } | {
13
+ name: string;
14
+ subcommands: {
15
+ name: string;
16
+ subcommands: never[];
17
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
18
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
19
+ name_localizations?: import("discord.js").LocalizationMap | null;
20
+ description: string;
21
+ description_localizations?: import("discord.js").LocalizationMap | null;
22
+ required?: boolean;
23
+ }[];
24
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
25
+ type: import("discord.js").ApplicationCommandOptionType.SubcommandGroup;
26
+ name_localizations?: import("discord.js").LocalizationMap | null;
27
+ description: string;
28
+ description_localizations?: import("discord.js").LocalizationMap | null;
29
+ required?: boolean;
30
+ } | {
31
+ subcommands: ({
32
+ name: string;
33
+ subcommands: never[];
34
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
35
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
36
+ name_localizations?: import("discord.js").LocalizationMap | null;
37
+ description: string;
38
+ description_localizations?: import("discord.js").LocalizationMap | null;
39
+ required?: boolean;
40
+ } | {
41
+ name: string;
42
+ subcommands: {
43
+ name: string;
44
+ subcommands: never[];
45
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
46
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
47
+ name_localizations?: import("discord.js").LocalizationMap | null;
48
+ description: string;
49
+ description_localizations?: import("discord.js").LocalizationMap | null;
50
+ required?: boolean;
51
+ }[];
52
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
53
+ type: import("discord.js").ApplicationCommandOptionType.SubcommandGroup;
54
+ name_localizations?: import("discord.js").LocalizationMap | null;
55
+ description: string;
56
+ description_localizations?: import("discord.js").LocalizationMap | null;
57
+ required?: boolean;
58
+ })[];
59
+ id: import("discord.js").Snowflake;
60
+ type: import("discord.js").ApplicationCommandType;
61
+ application_id: import("discord.js").Snowflake;
62
+ guild_id?: import("discord.js").Snowflake;
63
+ name: string;
64
+ name_localizations?: import("discord.js").LocalizationMap | null;
65
+ name_localized?: string;
66
+ description: string;
67
+ description_localizations?: import("discord.js").LocalizationMap | null;
68
+ description_localized?: string;
69
+ options?: import("discord.js").APIApplicationCommandOption[];
70
+ default_member_permissions: import("discord.js").Permissions | null;
71
+ dm_permission?: boolean;
72
+ default_permission?: boolean;
73
+ nsfw?: boolean;
74
+ integration_types?: import("discord.js").ApplicationIntegrationType[];
75
+ contexts?: import("discord.js").InteractionContextType[] | null;
76
+ version: import("discord.js").Snowflake;
77
+ handler?: import("discord.js").EntryPointCommandHandlerType;
78
+ })[];
10
79
  changed: {
11
- local: SlashCommandRuntime;
12
- remote: APIApplicationCommand;
80
+ local: import("../../../../../types.js").SlashCommandRuntime | import("../../../../../types.js").SlashCommandSubcommandRuntime | import("../../../../../types.js").SlashCommandSubcommandGroupRuntime;
81
+ remote: {
82
+ name: string;
83
+ subcommands: never[];
84
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
85
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
86
+ name_localizations?: import("discord.js").LocalizationMap | null;
87
+ description: string;
88
+ description_localizations?: import("discord.js").LocalizationMap | null;
89
+ required?: boolean;
90
+ } | {
91
+ name: string;
92
+ subcommands: {
93
+ name: string;
94
+ subcommands: never[];
95
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
96
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
97
+ name_localizations?: import("discord.js").LocalizationMap | null;
98
+ description: string;
99
+ description_localizations?: import("discord.js").LocalizationMap | null;
100
+ required?: boolean;
101
+ }[];
102
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
103
+ type: import("discord.js").ApplicationCommandOptionType.SubcommandGroup;
104
+ name_localizations?: import("discord.js").LocalizationMap | null;
105
+ description: string;
106
+ description_localizations?: import("discord.js").LocalizationMap | null;
107
+ required?: boolean;
108
+ } | {
109
+ subcommands: ({
110
+ name: string;
111
+ subcommands: never[];
112
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
113
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
114
+ name_localizations?: import("discord.js").LocalizationMap | null;
115
+ description: string;
116
+ description_localizations?: import("discord.js").LocalizationMap | null;
117
+ required?: boolean;
118
+ } | {
119
+ name: string;
120
+ subcommands: {
121
+ name: string;
122
+ subcommands: never[];
123
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
124
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
125
+ name_localizations?: import("discord.js").LocalizationMap | null;
126
+ description: string;
127
+ description_localizations?: import("discord.js").LocalizationMap | null;
128
+ required?: boolean;
129
+ }[];
130
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
131
+ type: import("discord.js").ApplicationCommandOptionType.SubcommandGroup;
132
+ name_localizations?: import("discord.js").LocalizationMap | null;
133
+ description: string;
134
+ description_localizations?: import("discord.js").LocalizationMap | null;
135
+ required?: boolean;
136
+ })[];
137
+ id: import("discord.js").Snowflake;
138
+ type: import("discord.js").ApplicationCommandType;
139
+ application_id: import("discord.js").Snowflake;
140
+ guild_id?: import("discord.js").Snowflake;
141
+ name: string;
142
+ name_localizations?: import("discord.js").LocalizationMap | null;
143
+ name_localized?: string;
144
+ description: string;
145
+ description_localizations?: import("discord.js").LocalizationMap | null;
146
+ description_localized?: string;
147
+ options?: import("discord.js").APIApplicationCommandOption[];
148
+ default_member_permissions: import("discord.js").Permissions | null;
149
+ dm_permission?: boolean;
150
+ default_permission?: boolean;
151
+ nsfw?: boolean;
152
+ integration_types?: import("discord.js").ApplicationIntegrationType[];
153
+ contexts?: import("discord.js").InteractionContextType[] | null;
154
+ version: import("discord.js").Snowflake;
155
+ handler?: import("discord.js").EntryPointCommandHandlerType;
156
+ };
13
157
  }[];
14
158
  synced: {
15
- local: SlashCommandRuntime;
16
- remote: APIApplicationCommand;
159
+ local: import("../../../../../types.js").SlashCommandRuntime | import("../../../../../types.js").SlashCommandSubcommandRuntime | import("../../../../../types.js").SlashCommandSubcommandGroupRuntime;
160
+ remote: {
161
+ name: string;
162
+ subcommands: never[];
163
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
164
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
165
+ name_localizations?: import("discord.js").LocalizationMap | null;
166
+ description: string;
167
+ description_localizations?: import("discord.js").LocalizationMap | null;
168
+ required?: boolean;
169
+ } | {
170
+ name: string;
171
+ subcommands: {
172
+ name: string;
173
+ subcommands: never[];
174
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
175
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
176
+ name_localizations?: import("discord.js").LocalizationMap | null;
177
+ description: string;
178
+ description_localizations?: import("discord.js").LocalizationMap | null;
179
+ required?: boolean;
180
+ }[];
181
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
182
+ type: import("discord.js").ApplicationCommandOptionType.SubcommandGroup;
183
+ name_localizations?: import("discord.js").LocalizationMap | null;
184
+ description: string;
185
+ description_localizations?: import("discord.js").LocalizationMap | null;
186
+ required?: boolean;
187
+ } | {
188
+ subcommands: ({
189
+ name: string;
190
+ subcommands: never[];
191
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
192
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
193
+ name_localizations?: import("discord.js").LocalizationMap | null;
194
+ description: string;
195
+ description_localizations?: import("discord.js").LocalizationMap | null;
196
+ required?: boolean;
197
+ } | {
198
+ name: string;
199
+ subcommands: {
200
+ name: string;
201
+ subcommands: never[];
202
+ options?: import("discord.js").APIApplicationCommandBasicOption[];
203
+ type: import("discord.js").ApplicationCommandOptionType.Subcommand;
204
+ name_localizations?: import("discord.js").LocalizationMap | null;
205
+ description: string;
206
+ description_localizations?: import("discord.js").LocalizationMap | null;
207
+ required?: boolean;
208
+ }[];
209
+ options?: import("discord.js").APIApplicationCommandSubcommandOption[];
210
+ type: import("discord.js").ApplicationCommandOptionType.SubcommandGroup;
211
+ name_localizations?: import("discord.js").LocalizationMap | null;
212
+ description: string;
213
+ description_localizations?: import("discord.js").LocalizationMap | null;
214
+ required?: boolean;
215
+ })[];
216
+ id: import("discord.js").Snowflake;
217
+ type: import("discord.js").ApplicationCommandType;
218
+ application_id: import("discord.js").Snowflake;
219
+ guild_id?: import("discord.js").Snowflake;
220
+ name: string;
221
+ name_localizations?: import("discord.js").LocalizationMap | null;
222
+ name_localized?: string;
223
+ description: string;
224
+ description_localizations?: import("discord.js").LocalizationMap | null;
225
+ description_localized?: string;
226
+ options?: import("discord.js").APIApplicationCommandOption[];
227
+ default_member_permissions: import("discord.js").Permissions | null;
228
+ dm_permission?: boolean;
229
+ default_permission?: boolean;
230
+ nsfw?: boolean;
231
+ integration_types?: import("discord.js").ApplicationIntegrationType[];
232
+ contexts?: import("discord.js").InteractionContextType[] | null;
233
+ version: import("discord.js").Snowflake;
234
+ handler?: import("discord.js").EntryPointCommandHandlerType;
235
+ };
17
236
  }[];
18
- conflict: SlashCommandRuntime[];
237
+ conflict: (import("../../../../../types.js").SlashCommandRuntime | import("../../../../../types.js").SlashCommandSubcommandRuntime | import("../../../../../types.js").SlashCommandSubcommandGroupRuntime)[];
19
238
  }>>;
20
239
  export default _default;
@@ -19,7 +19,7 @@ export default defineNitroPlugin(async (nitro) => {
19
19
  for (const cmd of data.commands) {
20
20
  const runtimeCommand = cmd;
21
21
  const buildPath = cmd.path.replace(runtimeConfig.discord.rootDir, runtimeConfig.discord.buildDir).replace(/\.ts$/, ".mjs");
22
- const existingCommand = slashCommands.find((c) => c.path === cmd.path);
22
+ const existingCommand = client.getSlashCommands().find((c) => c.path === cmd.path);
23
23
  if (fs.existsSync(buildPath)) {
24
24
  const lastModified = fs.statSync(buildPath).mtimeMs;
25
25
  runtimeCommand.load = () => import(`${buildPath}?${lastModified}`).then((m) => m.default);