nuxt-discord 0.1.0 → 0.2.1

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.
Files changed (52) hide show
  1. package/dist/module.d.mts +41 -1
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +131 -11
  4. package/dist/runtime/acknowledgement.d.ts +2 -1
  5. package/dist/runtime/acknowledgement.js +44 -12
  6. package/dist/runtime/client/components/CommandCard.d.ts +29 -0
  7. package/dist/runtime/client/components/CommandCard.js +75 -0
  8. package/dist/runtime/client/components/CommandReference.d.vue.ts +20 -0
  9. package/dist/runtime/client/components/CommandReference.vue +21 -0
  10. package/dist/runtime/client/components/CommandReference.vue.d.ts +20 -0
  11. package/dist/runtime/client/components/CommandTestBar.vue +0 -3
  12. package/dist/runtime/client/components/CommandsHeading.d.ts +24 -0
  13. package/dist/runtime/client/components/CommandsHeading.js +17 -0
  14. package/dist/runtime/client/components/DashboardHeader.d.ts +32 -0
  15. package/dist/runtime/client/components/DashboardHeader.js +32 -0
  16. package/dist/runtime/client/components/ProjectLogo.d.ts +4 -0
  17. package/dist/runtime/client/components/ProjectLogo.js +31 -0
  18. package/dist/runtime/client/components/ReferenceContent.d.ts +22 -0
  19. package/dist/runtime/client/components/ReferenceContent.js +45 -0
  20. package/dist/runtime/client/components/TheHeader.vue +33 -52
  21. package/dist/runtime/client/components/appearance-select.d.ts +1 -1
  22. package/dist/runtime/client/components/appearance-select.js +1 -1
  23. package/dist/runtime/client/pages/slash-commands.vue +28 -110
  24. package/dist/runtime/client/reference.css +133 -0
  25. package/dist/runtime/client/useDiscordCommandReference.d.ts +2 -0
  26. package/dist/runtime/client/useDiscordCommandReference.js +6 -0
  27. package/dist/runtime/dashboard/auth.js +10 -17
  28. package/dist/runtime/dashboard/oauth.d.ts +15 -1
  29. package/dist/runtime/dashboard/oauth.js +42 -21
  30. package/dist/runtime/dashboard/origin.d.ts +2 -0
  31. package/dist/runtime/dashboard/origin.js +8 -0
  32. package/dist/runtime/dashboard/signin.d.ts +2 -1
  33. package/dist/runtime/dashboard/signin.js +7 -2
  34. package/dist/runtime/dashboard/urls.d.ts +2 -0
  35. package/dist/runtime/dashboard/urls.js +8 -0
  36. package/dist/runtime/reference/access.d.ts +6 -0
  37. package/dist/runtime/reference/access.js +144 -0
  38. package/dist/runtime/reference/catalog.d.ts +2 -0
  39. package/dist/runtime/reference/catalog.js +9 -0
  40. package/dist/runtime/reference/document.d.ts +2 -0
  41. package/dist/runtime/reference/document.js +25 -0
  42. package/dist/runtime/reference/hosted.d.ts +2 -0
  43. package/dist/runtime/reference/hosted.js +16 -0
  44. package/dist/runtime/reference/oauth.d.ts +2 -0
  45. package/dist/runtime/reference/oauth.js +4 -0
  46. package/dist/runtime/server/plugins/discord.js +2 -0
  47. package/dist/types.d.mts +1 -1
  48. package/dist/types.d.ts +1 -1
  49. package/package.json +1 -1
  50. package/dist/runtime/client/components/ProjectLogo.d.vue.ts +0 -3
  51. package/dist/runtime/client/components/ProjectLogo.vue +0 -31
  52. package/dist/runtime/client/components/ProjectLogo.vue.d.ts +0 -3
@@ -0,0 +1,24 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ title: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ };
6
+ count: {
7
+ type: NumberConstructor;
8
+ required: true;
9
+ };
10
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
11
+ [key: string]: any;
12
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
13
+ title: {
14
+ type: StringConstructor;
15
+ default: string;
16
+ };
17
+ count: {
18
+ type: NumberConstructor;
19
+ required: true;
20
+ };
21
+ }>> & Readonly<{}>, {
22
+ title: string;
23
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
24
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { defineComponent, h } from "vue";
2
+ export default defineComponent({
3
+ name: "DiscordCommandsHeading",
4
+ props: {
5
+ title: { type: String, default: "Slash Commands" },
6
+ count: { type: Number, required: true }
7
+ },
8
+ setup(props, { slots }) {
9
+ return () => h("div", { class: "nd-commands-heading" }, [
10
+ h("div", [
11
+ h("h1", props.title),
12
+ h("p", `${props.count} ${props.count === 1 ? "command" : "commands"}`)
13
+ ]),
14
+ slots.default?.()
15
+ ]);
16
+ }
17
+ });
@@ -0,0 +1,32 @@
1
+ import type { PropType } from 'vue';
2
+ interface NavigationItem {
3
+ label: string;
4
+ href: string;
5
+ active?: boolean;
6
+ }
7
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ home: {
9
+ type: StringConstructor;
10
+ required: true;
11
+ };
12
+ items: {
13
+ type: PropType<NavigationItem[]>;
14
+ required: true;
15
+ };
16
+ hosted: BooleanConstructor;
17
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
18
+ [key: string]: any;
19
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
+ home: {
21
+ type: StringConstructor;
22
+ required: true;
23
+ };
24
+ items: {
25
+ type: PropType<NavigationItem[]>;
26
+ required: true;
27
+ };
28
+ hosted: BooleanConstructor;
29
+ }>> & Readonly<{}>, {
30
+ hosted: boolean;
31
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
32
+ export default _default;
@@ -0,0 +1,32 @@
1
+ import { defineComponent, h } from "vue";
2
+ import ProjectLogo from "./ProjectLogo.js";
3
+ export default defineComponent({
4
+ name: "DiscordDashboardHeader",
5
+ props: {
6
+ home: { type: String, required: true },
7
+ items: { type: Array, required: true },
8
+ hosted: Boolean
9
+ },
10
+ setup(props, { slots }) {
11
+ function navigation(mobile) {
12
+ return h("nav", { "class": mobile ? "nd-mobile-nav" : "nd-desktop-nav", "aria-label": "Dashboard" }, props.items.map((item) => {
13
+ const attrs = { "href": item.href, "aria-current": item.active ? "page" : void 0 };
14
+ return slots.link?.({ attrs, label: item.label }) ?? h("a", attrs, item.label);
15
+ }));
16
+ }
17
+ return () => h("header", { class: ["nd-header", { "nd-header-hosted": props.hosted }] }, [
18
+ h("a", { class: "nd-skip", href: "#discord-main" }, "Skip to content"),
19
+ h("div", { class: "nd-header-row" }, [
20
+ h("div", { class: "nd-header-start" }, [
21
+ h("a", { class: "nd-brand", href: props.home }, [
22
+ h(ProjectLogo, { "width": 32, "height": 32, "aria-hidden": "true" }),
23
+ h("span", "nuxt-discord")
24
+ ]),
25
+ navigation(false)
26
+ ]),
27
+ h("div", { class: "nd-header-actions" }, slots.default?.())
28
+ ]),
29
+ navigation(true)
30
+ ]);
31
+ }
32
+ });
@@ -0,0 +1,4 @@
1
+ declare const _default: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
2
+ [key: string]: any;
3
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
4
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import { defineComponent, h, useId } from "vue";
2
+ export default defineComponent({
3
+ name: "ProjectLogo",
4
+ setup() {
5
+ const seamMask = useId();
6
+ return () => h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "8 5.5 84 84", width: "84", height: "84" }, [
7
+ h("title", "Nuxt Discord"),
8
+ h("defs", [
9
+ h("mask", { id: seamMask, maskUnits: "userSpaceOnUse", x: "8", y: "5.5", width: "84", height: "84" }, [
10
+ h("rect", { x: "8", y: "5.5", width: "84", height: "84", fill: "white" }),
11
+ h("g", { transform: "translate(1.3 -.65) scale(.97) translate(6.32 3.64) scale(.94155)", fill: "black" }, [
12
+ h("path", { d: "M10 45.4C25.8 37.9 39.4 36.4 47.7 39.7 52.1 41.5 55.5 45.1 57.8 48.1Q58.2 48.7 57.6 49 57.2 49.2 56.8 48.7C54.2 45.9 50.8 43 47 41.6 38.9 38.5 26 41.1 10 49.7Z" }),
13
+ h("path", { d: "M57 19C62 23.4 66.6 30.5 67.05 37Q67.1 37.7 66.55 37.7 66.1 37.7 65.95 37.2C65.1 32.4 63.84 28.44 60.2 25.5Q56.8 22.75 53.9 19Z" })
14
+ ])
15
+ ])
16
+ ]),
17
+ h("g", { mask: `url(#${seamMask})` }, [
18
+ h("path", { fill: "#00dc82", style: "fill: light-dark(#00b574, #00dc82)", d: "M54.49 87.24C54.49 87.24 82.18 87.24 82.18 87.24 C83.06 87.24 83.91 86.93 84.67 86.49 C85.44 86.05 86.23 85.5 86.67 84.74 C87.11 83.98 87.42 83.12 87.42 82.25 C87.41 81.37 87.11 80.51 86.67 79.75 C86.67 79.75 67.96 47.58 67.96 47.58 C67.52 46.82 66.98 46.27 66.21 45.83 C65.45 45.39 64.35 45.08 63.47 45.08 C62.59 45.08 61.74 45.39 60.98 45.83 C60.21 46.27 59.67 46.82 59.23 47.58 C59.23 47.58 54.49 55.81 54.49 55.81 C54.49 55.81 45.01 39.84 45.01 39.84 C44.57 39.09 44.03 38.29 43.27 37.85 C42.5 37.41 41.65 37.35 40.77 37.35 C39.89 37.35 39.04 37.41 38.28 37.85 C37.51 38.29 36.72 39.09 36.28 39.84 C36.28 39.84 13.08 79.75 13.08 79.75 C12.64 80.51 12.59 81.37 12.58 82.25 C12.58 83.12 12.64 83.98 13.08 84.74 C13.53 85.5 14.31 86.05 15.08 86.49 C15.84 86.93 16.69 87.24 17.57 87.24 C17.57 87.24 35.03 87.24 35.03 87.24 C41.95 87.24 46.99 84.13 50.5 78.26 C50.5 78.26 58.98 63.54 58.98 63.54 C58.98 63.54 63.47 55.81 63.47 55.81 C63.47 55.81 77.19 79.26 77.19 79.26 C77.19 79.26 58.98 79.26 58.98 79.26 C58.98 79.26 54.49 87.24 54.49 87.24 C54.49 87.24 54.49 87.24 54.49 87.24 ZM34.78 79.26C34.78 79.26 22.56 79.26 22.56 79.26 C22.56 79.26 40.77 47.83 40.77 47.83 C40.77 47.83 50 63.54 50 63.54 C50 63.54 43.89 74.2 43.89 74.2 C41.56 78.01 38.9 79.26 34.78 79.26 C34.78 79.26 34.78 79.26 34.78 79.26 Z" }),
19
+ h("g", { transform: "translate(1.3 -.65) scale(.97)", fill: "#5865f2" }, [
20
+ h("g", { transform: "translate(6.32 3.64) scale(.94155)" }, [
21
+ h("path", { d: "M16.47 44.22C8 38.17 3.87 8.84 23.24 8.84 C40.6 8.84 53.4 20 60.2 25.5 C62.3 27.2 63.6 27.8 66.8 27.7 C74.1 27.7 79.7 28.4 81.5 32.4 C84.9 40 72.9 46.5 58.7 50C55.9 53.6 54.1 55.5 50.9 55.1 C40.6 53.1 30.4 46.2 12.4 54.1 Q10.2 55.1 10.9 52.9 Q12.3 48.3 16.47 44.22Z" })
22
+ ]),
23
+ h("g", { fill: "#fff" }, [
24
+ h("path", { d: "M23.78 24.8C25.16 24.39 26.8 25.77 27.44 27.9 C28.09 30.02 27.49 32.08 26.12 32.5 C24.75 32.92 23.11 31.53 22.46 29.41 C21.82 27.29 22.41 25.22 23.78 24.8 Z" }),
25
+ h("path", { d: "M31.25 26.36C30.22 24.37 30.53 22.17 31.93 21.45 C33.33 20.73 35.3 21.76 36.32 23.74 C37.35 25.73 37.04 27.93 35.64 28.65 C34.24 29.38 32.27 28.35 31.25 26.36 Z" })
26
+ ])
27
+ ])
28
+ ])
29
+ ]);
30
+ }
31
+ });
@@ -0,0 +1,22 @@
1
+ import type { PropType } from 'vue';
2
+ import type { DiscordCommandReference } from '../../../types.js';
3
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ catalog: {
5
+ type: PropType<DiscordCommandReference>;
6
+ required: true;
7
+ };
8
+ title: StringConstructor;
9
+ standalone: BooleanConstructor;
10
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
11
+ [key: string]: any;
12
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
13
+ catalog: {
14
+ type: PropType<DiscordCommandReference>;
15
+ required: true;
16
+ };
17
+ title: StringConstructor;
18
+ standalone: BooleanConstructor;
19
+ }>> & Readonly<{}>, {
20
+ standalone: boolean;
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
+ export default _default;
@@ -0,0 +1,45 @@
1
+ import { defineComponent, h } from "vue";
2
+ import CommandCard from "./CommandCard.js";
3
+ import CommandsHeading from "./CommandsHeading.js";
4
+ import DashboardHeader from "./DashboardHeader.js";
5
+ export default defineComponent({
6
+ name: "DiscordReferenceContent",
7
+ props: {
8
+ catalog: { type: Object, required: true },
9
+ title: String,
10
+ standalone: Boolean
11
+ },
12
+ setup(props, { slots }) {
13
+ function commandCard(command) {
14
+ const footer = slots["command-footer"];
15
+ return h(CommandCard, { key: command.name, command, anchor: `command-${command.name.replaceAll(" ", "/")}` }, footer && { footer: () => footer({ command }) });
16
+ }
17
+ function menuSection() {
18
+ return h("section", { class: "nd-menus", id: "context-menus" }, [
19
+ h("h2", "Context Menus"),
20
+ h("dl", props.catalog.menus.map((menu) => h("div", { key: `${menu.type}:${menu.name}`, class: "nd-command-card nd-menu" }, [
21
+ h("dt", menu.name),
22
+ h("dd", `Open the Apps menu on a ${menu.type}.`)
23
+ ])))
24
+ ]);
25
+ }
26
+ return () => {
27
+ const { catalog, standalone } = props;
28
+ const items = [{ label: "Commands", href: "#discord-main", active: true }];
29
+ if (catalog.menus.length)
30
+ items.push({ label: "Context Menus", href: "#context-menus", active: false });
31
+ const content = [
32
+ h(CommandsHeading, { title: props.title ?? (standalone ? "Slash Commands" : "Command reference"), count: catalog.commands.length }),
33
+ !standalone && slots.default?.(),
34
+ h("hr", { class: "nd-divider" }),
35
+ ...catalog.commands.map(commandCard),
36
+ !catalog.commands.length && h("p", { class: "nd-empty" }, "No commands yet"),
37
+ catalog.menus.length ? menuSection() : null
38
+ ];
39
+ return standalone ? h("div", { class: "nd-reference-page" }, [
40
+ h(DashboardHeader, { home: "#discord-main", items }, { default: () => [slots["admin-entry"]?.(), slots.default?.()] }),
41
+ h("main", { id: "discord-main", class: "discord-reference", tabindex: -1 }, content)
42
+ ]) : h("article", { class: "discord-reference" }, content);
43
+ };
44
+ }
45
+ });
@@ -1,62 +1,43 @@
1
1
  <script setup>
2
+ import { computed } from "vue";
2
3
  import { useRoute } from "#imports";
3
4
  import { appearanceSelect } from "./appearance-select";
4
- import ProjectLogo from "./ProjectLogo.vue";
5
+ import DashboardHeader from "./DashboardHeader";
5
6
  const route = useRoute();
6
7
  const hosted = !import.meta.dev;
7
- const nav = [
8
- { label: "Overview", to: "/discord" },
9
- { label: "Commands", to: "/discord/slash-commands" },
10
- { label: "Context Menus", to: "/discord/context-menus" },
11
- { label: "Listeners", to: "/discord/listeners" },
12
- { label: "Activity", to: "/discord/activity" }
13
- ];
8
+ const nav = computed(() => [
9
+ { label: "Overview", href: "/discord" },
10
+ { label: "Commands", href: "/discord/slash-commands" },
11
+ { label: "Context Menus", href: "/discord/context-menus" },
12
+ { label: "Listeners", href: "/discord/listeners" },
13
+ { label: "Activity", href: "/discord/activity" }
14
+ ].map((item) => ({ ...item, active: route.path === item.href })));
14
15
  </script>
15
16
 
16
17
  <template>
17
- <header class="sticky top-0 z-50 w-full border-b border-default bg-default/80 backdrop-blur-xl">
18
- <a href="#discord-main" class="sr-only focus:not-sr-only">Skip to content</a>
19
- <div class="mx-auto flex h-14 max-w-6xl items-center justify-between px-6">
20
- <div class="flex items-center gap-6">
21
- <NuxtLink to="/discord" class="flex items-center gap-2.5">
22
- <ProjectLogo width="32" height="32" aria-hidden="true" class="shrink-0" />
23
- <span class="text-sm font-semibold tracking-tight">nuxt-discord</span>
24
- </NuxtLink>
25
-
26
- <nav class="hidden items-center gap-1" :class="hosted ? 'md:flex' : 'sm:flex'">
27
- <NuxtLink
28
- v-for="item in nav"
29
- :key="item.to"
30
- :to="item.to"
31
- class="px-2.5 py-1 text-xs font-medium rounded-md transition-colors"
32
- :class="route.path === item.to ? 'text-highlighted bg-elevated' : 'text-muted hover:text-highlighted hover:bg-elevated/50'"
33
- >
34
- {{ item.label }}
35
- </NuxtLink>
36
- </nav>
37
- </div>
38
-
39
- <div class="flex items-center gap-1">
40
- <UColorModeSelect v-bind="appearanceSelect" />
41
- <a
42
- href="https://github.com/zojize/nuxt-discord"
43
- target="_blank"
44
- title="View on GitHub"
45
- class="flex size-8 cursor-pointer items-center justify-center rounded-md text-muted transition-colors hover:bg-elevated hover:text-highlighted"
46
- >
47
- <UIcon name="i-simple-icons-github" class="size-4" />
48
- </a>
49
- <form v-if="hosted" method="post" action="/__discord-auth/logout">
50
- <button type="submit" class="min-h-11 cursor-pointer rounded-md px-2 text-sm font-medium text-muted hover:bg-elevated hover:text-highlighted focus-visible:outline-2 focus-visible:outline-primary">
51
- Sign out
52
- </button>
53
- </form>
54
- </div>
55
- </div>
56
- <nav aria-label="Dashboard" class="flex gap-3 overflow-x-auto border-t border-default px-4 py-2 text-sm" :class="hosted ? 'md:hidden' : 'sm:hidden'">
57
- <NuxtLink v-for="item in nav" :key="item.to" :to="item.to" class="shrink-0" exact-active-class="font-bold">
58
- {{ item.label }}
18
+ <DashboardHeader home="/discord" :items="nav" :hosted="hosted">
19
+ <template #link="{ attrs, label }">
20
+ <NuxtLink :to="attrs.href" :aria-current="attrs['aria-current']">
21
+ {{ label }}
59
22
  </NuxtLink>
60
- </nav>
61
- </header>
23
+ </template>
24
+ <UColorModeSelect v-bind="appearanceSelect" />
25
+ <a
26
+ href="https://github.com/zojize/nuxt-discord"
27
+ target="_blank"
28
+ title="View on GitHub"
29
+ class="flex size-8 cursor-pointer items-center justify-center rounded-md text-muted transition-colors hover:bg-elevated hover:text-highlighted"
30
+ >
31
+ <UIcon name="i-simple-icons-github" class="size-4" />
32
+ </a>
33
+ <form v-if="hosted" method="post" action="/__discord-auth/logout">
34
+ <button type="submit" class="min-h-11 cursor-pointer rounded-md px-2 text-sm font-medium text-muted hover:bg-elevated hover:text-highlighted focus-visible:outline-2 focus-visible:outline-primary">
35
+ Sign out
36
+ </button>
37
+ </form>
38
+ </DashboardHeader>
62
39
  </template>
40
+
41
+ <style src="../reference.css">
42
+
43
+ </style>
@@ -7,7 +7,7 @@ export declare const appearanceSelect: {
7
7
  readonly align: "end";
8
8
  };
9
9
  readonly ui: {
10
- readonly base: "size-11 shrink-0 justify-center p-0";
10
+ readonly base: "size-11 shrink-0 cursor-pointer justify-center p-0";
11
11
  readonly leading: "static p-0";
12
12
  readonly leadingIcon: "size-[1.125rem] text-current";
13
13
  readonly value: "sr-only";
@@ -5,7 +5,7 @@ export const appearanceSelect = {
5
5
  "color": "neutral",
6
6
  "content": { align: "end" },
7
7
  "ui": {
8
- base: "size-11 shrink-0 justify-center p-0",
8
+ base: "size-11 shrink-0 cursor-pointer justify-center p-0",
9
9
  leading: "static p-0",
10
10
  leadingIcon: "size-[1.125rem] text-current",
11
11
  value: "sr-only",
@@ -1,33 +1,10 @@
1
1
  <script setup>
2
2
  import { computed, ref, useFetch } from "#imports";
3
+ import CommandCard from "../components/CommandCard";
4
+ import CommandsHeading from "../components/CommandsHeading";
3
5
  import CommandTestBar from "../components/CommandTestBar.vue";
4
6
  import TheHeader from "../components/TheHeader.vue";
5
7
  import { useCommandRegistry } from "../useCommandRegistry";
6
- var ApplicationCommandOptionType = /* @__PURE__ */ ((ApplicationCommandOptionType2) => {
7
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["Subcommand"] = 1] = "Subcommand";
8
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["SubcommandGroup"] = 2] = "SubcommandGroup";
9
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["String"] = 3] = "String";
10
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["Integer"] = 4] = "Integer";
11
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["Boolean"] = 5] = "Boolean";
12
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["User"] = 6] = "User";
13
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["Channel"] = 7] = "Channel";
14
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["Role"] = 8] = "Role";
15
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["Mentionable"] = 9] = "Mentionable";
16
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["Number"] = 10] = "Number";
17
- ApplicationCommandOptionType2[ApplicationCommandOptionType2["Attachment"] = 11] = "Attachment";
18
- return ApplicationCommandOptionType2;
19
- })(ApplicationCommandOptionType || {});
20
- const typeConfig = {
21
- [3 /* String */]: { label: "str", color: "primary" },
22
- [4 /* Integer */]: { label: "int", color: "info" },
23
- [10 /* Number */]: { label: "num", color: "info" },
24
- [5 /* Boolean */]: { label: "bool", color: "success" },
25
- [6 /* User */]: { label: "user", color: "secondary" },
26
- [7 /* Channel */]: { label: "chan", color: "warning" },
27
- [8 /* Role */]: { label: "role", color: "secondary" },
28
- [9 /* Mentionable */]: { label: "@", color: "secondary" },
29
- [11 /* Attachment */]: { label: "file", color: "neutral" }
30
- };
31
8
  function getRemoteId(command) {
32
9
  if ("remote" in command && command.remote?.id)
33
10
  return command.remote.id;
@@ -97,20 +74,6 @@ const statusMeta = {
97
74
  removed: { color: "neutral", classes: "border-dashed border-neutral-400/40 opacity-60" },
98
75
  conflict: { color: "error", classes: "border-dashed border-red-500/40" }
99
76
  };
100
- function constraintBadges(option) {
101
- const badges = [];
102
- if ("min" in option && option.min !== void 0)
103
- badges.push(`>=${option.min}`);
104
- if ("max" in option && option.max !== void 0)
105
- badges.push(`<=${option.max}`);
106
- if ("minLength" in option && option.minLength !== void 0)
107
- badges.push(`len>=${option.minLength}`);
108
- if ("maxLength" in option && option.maxLength !== void 0)
109
- badges.push(`len<=${option.maxLength}`);
110
- if ("choices" in option && option.choices?.length)
111
- badges.push(`${option.choices.length} choices`);
112
- return badges;
113
- }
114
77
  </script>
115
78
 
116
79
  <template>
@@ -118,16 +81,7 @@ function constraintBadges(option) {
118
81
  <TheHeader />
119
82
 
120
83
  <main id="discord-main" tabindex="-1" class="mx-auto px-6 py-8 pb-24 max-w-6xl">
121
- <!-- Title bar -->
122
- <div class="mb-8 flex items-start justify-between">
123
- <div>
124
- <h1 class="text-2xl tracking-tight font-bold">
125
- Slash Commands
126
- </h1>
127
- <p class="text-muted text-sm mt-1">
128
- {{ commandsWithStatus.length }} command{{ commandsWithStatus.length === 1 ? "" : "s" }}
129
- </p>
130
- </div>
84
+ <CommandsHeading :count="commandsWithStatus.length">
131
85
  <UButton
132
86
  v-if="canManage && !allSynced"
133
87
  label="Sync to Discord"
@@ -139,7 +93,7 @@ function constraintBadges(option) {
139
93
  :disabled="stats.conflict > 0"
140
94
  @click="syncCommands"
141
95
  />
142
- </div>
96
+ </CommandsHeading>
143
97
 
144
98
  <div role="status" aria-atomic="true">
145
99
  <p v-if="syncFeedback" class="mb-3 border-s-2 ps-3 text-sm" :class="syncFeedback.failed ? 'border-error' : 'border-success'">
@@ -169,75 +123,39 @@ function constraintBadges(option) {
169
123
 
170
124
  <!-- Commands -->
171
125
  <div v-if="sortedCommands.length > 0" class="space-y-3">
172
- <UCard
126
+ <CommandCard
173
127
  v-for="command in sortedCommands"
174
128
  :key="command.scope + command.name"
175
- variant="outline"
129
+ :command="command"
176
130
  :class="statusMeta[command.status].classes"
177
- :ui="command.options.length === 0 ? { body: 'hidden' } : {}"
178
131
  >
179
- <template #header>
180
- <div class="flex gap-4 items-start justify-between">
181
- <div class="flex-1 min-w-0">
182
- <div class="flex flex-wrap gap-2 items-center">
183
- <code class="text-highlighted text-base font-semibold">/{{ command.name }}</code>
184
- <span v-if="command.scope" class="text-xs text-muted">{{ command.scope }}</span>
185
- <UBadge
186
- :color="statusMeta[command.status].color"
187
- variant="subtle"
188
- size="xs"
189
- :label="command.status"
190
- />
191
- <UBadge v-if="'nsfw' in command && command.nsfw" label="nsfw" color="error" variant="soft" size="xs" />
192
- <UBadge v-if="'guilds' in command && command.guilds" :label="command.guilds === true ? 'guild' : `guild: ${Array.isArray(command.guilds) ? command.guilds.length : 1}`" color="warning" variant="soft" size="xs" />
193
- <UBadge v-if="'contexts' in command && command.contexts?.length === 1" label="no DM" color="neutral" variant="outline" size="xs" />
194
- <UBadge v-if="'defaultMemberPermissions' in command && command.defaultMemberPermissions" label="restricted" color="warning" variant="outline" size="xs" :title="`permissions: ${command.defaultMemberPermissions}`" />
195
- </div>
196
- <p class="text-muted text-sm mt-1">
197
- {{ command.description }}
198
- </p>
199
- </div>
200
-
201
- <div class="pt-0.5 flex shrink-0 flex-wrap gap-1.5 items-center">
202
- <UBadge
203
- v-if="'subcommands' in command && (command.subcommands?.length ?? 0) > 0"
204
- :label="`${command.subcommands.length} sub`"
205
- color="info" variant="soft" size="xs"
206
- />
207
- <UBadge
208
- v-if="getRemoteId(command)"
209
- label="registered" color="success" variant="soft" size="xs"
210
- :title="`ID: ${getRemoteId(command)}`"
211
- />
212
- </div>
213
- </div>
132
+ <template #badges>
133
+ <span v-if="command.scope" class="text-xs text-muted">{{ command.scope }}</span>
134
+ <UBadge
135
+ :color="statusMeta[command.status].color"
136
+ variant="subtle"
137
+ size="xs"
138
+ :label="command.status"
139
+ />
140
+ <UBadge v-if="'nsfw' in command && command.nsfw" label="nsfw" color="error" variant="soft" size="xs" />
141
+ <UBadge v-if="'guilds' in command && command.guilds" :label="command.guilds === true ? 'guild' : `guild: ${Array.isArray(command.guilds) ? command.guilds.length : 1}`" color="warning" variant="soft" size="xs" />
142
+ <UBadge v-if="'contexts' in command && command.contexts?.length === 1" label="no DM" color="neutral" variant="outline" size="xs" />
143
+ <UBadge v-if="'defaultMemberPermissions' in command && command.defaultMemberPermissions" label="restricted" color="warning" variant="outline" size="xs" :title="`permissions: ${command.defaultMemberPermissions}`" />
214
144
  </template>
215
-
216
- <!-- Options (body hidden via ui prop when empty) -->
217
- <div v-if="command.options.length > 0" class="flex flex-wrap gap-2">
218
- <div
219
- v-for="option in command.options"
220
- :key="option.name"
221
- :title="option.description || option.name"
222
- class="border-default bg-elevated text-xs px-2.5 py-1.5 border rounded-md flex gap-1.5 items-center cursor-default"
223
- >
224
- <span class="font-medium">{{ option.name }}</span>
225
- <span v-if="!option.required" class="text-dimmed">?</span>
145
+ <template #meta>
146
+ <div class="pt-0.5 flex shrink-0 flex-wrap gap-1.5 items-center">
226
147
  <UBadge
227
- :label="typeConfig[option.type]?.label ?? '?'"
228
- :color="typeConfig[option.type]?.color ?? 'neutral'"
229
- variant="subtle" size="xs"
148
+ v-if="'subcommands' in command && (command.subcommands?.length ?? 0) > 0"
149
+ :label="`${command.subcommands.length} sub`"
150
+ color="info" variant="soft" size="xs"
230
151
  />
231
152
  <UBadge
232
- v-for="c in constraintBadges(option)" :key="c"
233
- :label="c" color="neutral" variant="outline" size="xs"
234
- />
235
- <UBadge
236
- v-if="option.hasAutocomplete"
237
- label="auto" color="info" variant="outline" size="xs"
153
+ v-if="getRemoteId(command)"
154
+ label="registered" color="success" variant="soft" size="xs"
155
+ :title="`ID: ${getRemoteId(command)}`"
238
156
  />
239
157
  </div>
240
- </div>
158
+ </template>
241
159
 
242
160
  <template v-if="showEditorLinks && command.path || getRemoteId(command)" #footer>
243
161
  <div class="text-dimmed text-xs flex items-center justify-between">
@@ -245,7 +163,7 @@ function constraintBadges(option) {
245
163
  <span v-if="getRemoteId(command)" class="font-mono shrink-0">{{ getRemoteId(command) }}</span>
246
164
  </div>
247
165
  </template>
248
- </UCard>
166
+ </CommandCard>
249
167
  </div>
250
168
 
251
169
  <!-- Empty state -->