nuxt-discord 0.0.17 → 0.2.0

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 (132) hide show
  1. package/README.md +249 -171
  2. package/dist/module.d.mts +146 -10
  3. package/dist/module.json +3 -3
  4. package/dist/module.mjs +1077 -348
  5. package/dist/runtime/acknowledgement.d.ts +11 -0
  6. package/dist/runtime/acknowledgement.js +156 -0
  7. package/dist/runtime/client/chat-theme.css +52 -0
  8. package/dist/runtime/client/components/ChatAvatar.d.vue.ts +6 -0
  9. package/dist/runtime/client/components/ChatAvatar.vue +11 -0
  10. package/dist/runtime/client/components/ChatAvatar.vue.d.ts +6 -0
  11. package/dist/runtime/client/components/CommandPicker.d.vue.ts +24 -0
  12. package/dist/runtime/client/components/CommandPicker.vue +67 -0
  13. package/dist/runtime/client/components/CommandPicker.vue.d.ts +24 -0
  14. package/dist/runtime/client/components/CommandReference.d.vue.ts +20 -0
  15. package/dist/runtime/client/components/CommandReference.vue +21 -0
  16. package/dist/runtime/client/components/CommandReference.vue.d.ts +20 -0
  17. package/dist/runtime/client/components/CommandTestBar.d.vue.ts +60 -0
  18. package/dist/runtime/client/components/CommandTestBar.vue +332 -0
  19. package/dist/runtime/client/components/CommandTestBar.vue.d.ts +60 -0
  20. package/dist/runtime/client/components/CommandTranscript.d.vue.ts +39 -0
  21. package/dist/runtime/client/components/CommandTranscript.vue +147 -0
  22. package/dist/runtime/client/components/CommandTranscript.vue.d.ts +39 -0
  23. package/dist/runtime/client/components/ProjectLogo.d.vue.ts +3 -0
  24. package/dist/runtime/client/components/ProjectLogo.vue +31 -0
  25. package/dist/runtime/client/components/ProjectLogo.vue.d.ts +3 -0
  26. package/dist/runtime/client/components/ReferenceContent.d.ts +26 -0
  27. package/dist/runtime/client/components/ReferenceContent.js +73 -0
  28. package/dist/runtime/client/components/TheHeader.d.vue.ts +3 -0
  29. package/dist/runtime/client/components/TheHeader.vue +53 -16
  30. package/dist/runtime/client/components/TheHeader.vue.d.ts +2 -2
  31. package/dist/runtime/client/components/appearance-select.d.ts +17 -0
  32. package/dist/runtime/client/components/appearance-select.js +15 -0
  33. package/dist/runtime/client/pages/activity.d.vue.ts +3 -0
  34. package/dist/runtime/client/pages/activity.vue +202 -0
  35. package/dist/runtime/client/pages/activity.vue.d.ts +3 -0
  36. package/dist/runtime/client/pages/context-menus.d.vue.ts +3 -0
  37. package/dist/runtime/client/pages/context-menus.vue +120 -0
  38. package/dist/runtime/client/pages/context-menus.vue.d.ts +3 -0
  39. package/dist/runtime/client/pages/listeners.d.vue.ts +3 -0
  40. package/dist/runtime/client/pages/listeners.vue +68 -0
  41. package/dist/runtime/client/pages/listeners.vue.d.ts +3 -0
  42. package/dist/runtime/client/pages/overview.d.vue.ts +3 -0
  43. package/dist/runtime/client/pages/overview.vue +280 -0
  44. package/dist/runtime/client/pages/overview.vue.d.ts +3 -0
  45. package/dist/runtime/client/pages/slash-commands.d.vue.ts +3 -0
  46. package/dist/runtime/client/pages/slash-commands.vue +185 -359
  47. package/dist/runtime/client/pages/slash-commands.vue.d.ts +2 -3
  48. package/dist/runtime/client/reference.css +46 -0
  49. package/dist/runtime/client/style.css +4 -1
  50. package/dist/runtime/client/useActivityLog.d.ts +7 -0
  51. package/dist/runtime/client/useActivityLog.js +76 -0
  52. package/dist/runtime/client/useCommandRegistry.d.ts +7 -0
  53. package/dist/runtime/client/useCommandRegistry.js +34 -0
  54. package/dist/runtime/client/useDashboardCatalog.d.ts +5 -0
  55. package/dist/runtime/client/useDashboardCatalog.js +9 -0
  56. package/dist/runtime/client/useDiscordCommandReference.d.ts +2 -0
  57. package/dist/runtime/client/useDiscordCommandReference.js +6 -0
  58. package/dist/runtime/dashboard/auth.d.ts +4 -0
  59. package/dist/runtime/dashboard/auth.js +55 -0
  60. package/dist/runtime/dashboard/oauth.d.ts +17 -0
  61. package/dist/runtime/dashboard/oauth.js +172 -0
  62. package/dist/runtime/dashboard/origin.d.ts +3 -0
  63. package/dist/runtime/dashboard/origin.js +15 -0
  64. package/dist/runtime/dashboard/permissions.d.ts +4 -0
  65. package/dist/runtime/dashboard/permissions.js +84 -0
  66. package/dist/runtime/dashboard/signin.d.ts +3 -0
  67. package/dist/runtime/dashboard/signin.js +42 -0
  68. package/dist/runtime/diagnostics.d.ts +4 -0
  69. package/dist/runtime/diagnostics.js +24 -0
  70. package/dist/runtime/discordInvocation.d.ts +14 -0
  71. package/dist/runtime/discordInvocation.js +28 -0
  72. package/dist/runtime/middleware.d.ts +1 -0
  73. package/dist/runtime/middleware.js +12 -0
  74. package/dist/runtime/reference/access.d.ts +6 -0
  75. package/dist/runtime/reference/access.js +143 -0
  76. package/dist/runtime/reference/catalog.d.ts +2 -0
  77. package/dist/runtime/reference/catalog.js +9 -0
  78. package/dist/runtime/reference/document.d.ts +2 -0
  79. package/dist/runtime/reference/document.js +22 -0
  80. package/dist/runtime/reference/hosted.d.ts +2 -0
  81. package/dist/runtime/reference/hosted.js +16 -0
  82. package/dist/runtime/reference/oauth.d.ts +2 -0
  83. package/dist/runtime/reference/oauth.js +4 -0
  84. package/dist/runtime/registration.d.ts +65 -0
  85. package/dist/runtime/registration.js +354 -0
  86. package/dist/runtime/server/api/discord/activity.get.d.ts +2 -0
  87. package/dist/runtime/server/api/discord/activity.get.js +6 -0
  88. package/dist/runtime/server/api/discord/catalog.get.d.ts +2 -0
  89. package/dist/runtime/server/api/discord/catalog.get.js +3 -0
  90. package/dist/runtime/server/api/discord/slash-command/autocomplete.post.d.ts +2 -0
  91. package/dist/runtime/server/api/discord/slash-command/autocomplete.post.js +14 -0
  92. package/dist/runtime/server/api/discord/slash-command/register.post.d.ts +1 -1
  93. package/dist/runtime/server/api/discord/slash-command/register.post.js +1 -1
  94. package/dist/runtime/server/api/discord/slash-command/remote-all.get.d.ts +1 -1
  95. package/dist/runtime/server/api/discord/slash-command/remote-diff.post.d.ts +1 -238
  96. package/dist/runtime/server/api/discord/slash-command/remote-diff.post.js +3 -1
  97. package/dist/runtime/server/api/discord/slash-command/test.post.d.ts +20 -0
  98. package/dist/runtime/server/api/discord/slash-command/test.post.js +19 -0
  99. package/dist/runtime/server/plugins/discord.js +95 -31
  100. package/dist/runtime/server/utils/client.d.ts +59 -246
  101. package/dist/runtime/server/utils/client.js +413 -451
  102. package/dist/runtime/server/utils/defineContextMenu.d.ts +49 -0
  103. package/dist/runtime/server/utils/defineContextMenu.js +12 -0
  104. package/dist/runtime/server/utils/defineListener.d.ts +24 -0
  105. package/dist/runtime/server/utils/defineListener.js +7 -0
  106. package/dist/runtime/server/utils/defineMiddleware.d.ts +29 -0
  107. package/dist/runtime/server/utils/defineMiddleware.js +24 -0
  108. package/dist/runtime/server/utils/describeCommand.d.ts +2 -0
  109. package/dist/runtime/server/utils/describeOption.d.ts +1 -1
  110. package/dist/runtime/server/utils/messageSender.d.ts +37 -0
  111. package/dist/runtime/server/utils/messageSender.js +149 -0
  112. package/dist/runtime/server/utils/middleware/cooldown.d.ts +1 -0
  113. package/dist/runtime/server/utils/middleware/cooldown.js +39 -0
  114. package/dist/runtime/server/utils/middleware/guildOnly.d.ts +1 -0
  115. package/dist/runtime/server/utils/middleware/guildOnly.js +6 -0
  116. package/dist/runtime/server/utils/middleware/ownerOnly.d.ts +1 -0
  117. package/dist/runtime/server/utils/middleware/ownerOnly.js +10 -0
  118. package/dist/runtime/server/utils/middleware/requireRole.d.ts +1 -0
  119. package/dist/runtime/server/utils/middleware/requireRole.js +15 -0
  120. package/dist/runtime/server/utils/reply.d.ts +13 -3
  121. package/dist/runtime/server/utils/reply.js +111 -162
  122. package/dist/runtime/server/utils/simulateInteraction.d.ts +20 -0
  123. package/dist/runtime/server/utils/simulateInteraction.js +127 -0
  124. package/dist/runtime/server/utils/useTextChannel.d.ts +56 -0
  125. package/dist/runtime/server/utils/useTextChannel.js +105 -0
  126. package/dist/types.d.mts +11 -1
  127. package/dist/types.d.ts +11 -1
  128. package/package.json +62 -44
  129. package/dist/runtime/client/components/TheHeader.css +0 -1
  130. package/dist/runtime/client/pages/slash-commands.css +0 -1
  131. package/dist/runtime/client/uno.config.d.ts +0 -2
  132. package/dist/runtime/client/uno.config.js +0 -10
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,26 @@
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: {
9
+ type: StringConstructor;
10
+ default: string;
11
+ };
12
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
13
+ [key: string]: any;
14
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
15
+ catalog: {
16
+ type: PropType<DiscordCommandReference>;
17
+ required: true;
18
+ };
19
+ title: {
20
+ type: StringConstructor;
21
+ default: string;
22
+ };
23
+ }>> & Readonly<{}>, {
24
+ title: string;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
26
+ export default _default;
@@ -0,0 +1,73 @@
1
+ import { defineComponent, h } from "vue";
2
+ function commandId(name) {
3
+ return `command-${name.replaceAll(" ", "/")}`;
4
+ }
5
+ function optionRow(option) {
6
+ const limits = [];
7
+ if (option.min !== void 0)
8
+ limits.push(`Minimum ${option.min}`);
9
+ if (option.max !== void 0)
10
+ limits.push(`Maximum ${option.max}`);
11
+ if (option.minLength !== void 0)
12
+ limits.push(`Minimum length ${option.minLength}`);
13
+ if (option.maxLength !== void 0)
14
+ limits.push(`Maximum length ${option.maxLength}`);
15
+ if (option.hasAutocomplete)
16
+ limits.push("Autocomplete");
17
+ return h("div", { key: option.name, class: "ref-option" }, [
18
+ h("dt", [
19
+ h("code", option.name),
20
+ " ",
21
+ h("small", `${option.type} \xB7 ${option.required ? "Required" : "Optional"}`)
22
+ ]),
23
+ h("dd", [
24
+ option.description,
25
+ limits.length ? h("span", { class: "ref-meta" }, limits.join(" \xB7 ")) : null,
26
+ option.choices?.length ? h("span", { class: "ref-meta" }, `Choices \xB7 ${option.choices.map((choice) => choice.name).join(", ")}`) : null
27
+ ])
28
+ ]);
29
+ }
30
+ export default defineComponent({
31
+ name: "DiscordReferenceContent",
32
+ props: {
33
+ catalog: { type: Object, required: true },
34
+ title: { type: String, default: "Command reference" }
35
+ },
36
+ setup(props, { slots }) {
37
+ function navigation() {
38
+ const links = props.catalog.commands.map(
39
+ (cmd) => h("li", { key: cmd.name }, [h("a", { href: `#${encodeURIComponent(commandId(cmd.name))}` }, [h("code", `/${cmd.name}`)])])
40
+ );
41
+ if (props.catalog.menus.length)
42
+ links.push(h("li", { key: "context-menus-link" }, [h("a", { href: "#context-menus" }, "Context menus")]));
43
+ return h("nav", { "class": "ref-nav", "aria-label": "On this page" }, [h("p", "On this page"), h("ul", links)]);
44
+ }
45
+ function commandSection(cmd) {
46
+ return h("section", { key: cmd.name, class: "ref-command" }, [
47
+ h("h3", { id: commandId(cmd.name) }, [h("code", `/${cmd.name}`)]),
48
+ h("p", cmd.description),
49
+ cmd.options.length ? h("dl", cmd.options.map(optionRow)) : null,
50
+ slots["command-footer"]?.({ command: cmd })
51
+ ]);
52
+ }
53
+ function menuSection() {
54
+ return h("section", [
55
+ h("h2", { id: "context-menus" }, "Context menus"),
56
+ h("dl", props.catalog.menus.map((menu) => h("div", { key: `${menu.type}:${menu.name}`, class: "ref-option" }, [
57
+ h("dt", menu.name),
58
+ h("dd", `Open the Apps menu on a ${menu.type}.`)
59
+ ])))
60
+ ]);
61
+ }
62
+ return () => h("article", { class: "discord-reference" }, [
63
+ h("header", { class: "ref-header" }, [h("h1", props.title), slots.default?.()]),
64
+ props.catalog.commands.length || props.catalog.menus.length ? h("div", { class: "ref-layout" }, [
65
+ navigation(),
66
+ h("div", { class: "ref-content" }, [
67
+ props.catalog.commands.length ? h("section", [h("h2", "Slash commands"), ...props.catalog.commands.map(commandSection)]) : null,
68
+ props.catalog.menus.length ? menuSection() : null
69
+ ])
70
+ ]) : h("p", "No commands or context menus are listed.")
71
+ ]);
72
+ }
73
+ });
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -1,25 +1,62 @@
1
1
  <script setup>
2
- import { useDark } from "@vueuse/core";
3
- import "./TheHeader.css";
4
- const dark = useDark();
2
+ import { useRoute } from "#imports";
3
+ import { appearanceSelect } from "./appearance-select";
4
+ import ProjectLogo from "./ProjectLogo.vue";
5
+ const route = useRoute();
6
+ 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
+ ];
5
14
  </script>
6
15
 
7
16
  <template>
8
- <header class="bg-default/75 border-default border-b flex h-16 w-full top-0 justify-center sticky z-10 backdrop-blur">
9
- <div class="mx-auto px-6 container flex items-center justify-between">
10
- <ULink to="/discord/slash-commands" :active="false">
11
- <h1 class="text-2xl font-bold">
12
- <span class="text-primary"> Nuxt </span>
13
- <span class="text-secondary"> Discord </span>
14
- </h1>
15
- </ULink>
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>
16
25
 
17
- <div class="flex gap-4 items-center justify-center">
18
- <USwitch v-model="dark" unchecked-icon="i-lucide-sun" checked-icon="i-lucide-moon" size="xl" />
19
- <ULink to="http://github.com/zojize/nuxt-discord" target="_blank" external class="flex items-center">
20
- <UIcon name="i-simple-icons:github" size="1.25rem" />
21
- </ULink>
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>
22
54
  </div>
23
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 }}
59
+ </NuxtLink>
60
+ </nav>
24
61
  </header>
25
62
  </template>
@@ -1,3 +1,3 @@
1
- import './TheHeader.css.js';
2
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
3
  export default _default;
@@ -0,0 +1,17 @@
1
+ export declare const appearanceSelect: {
2
+ readonly 'aria-label': "Appearance";
3
+ readonly title: "Appearance";
4
+ readonly variant: "ghost";
5
+ readonly color: "neutral";
6
+ readonly content: {
7
+ readonly align: "end";
8
+ };
9
+ readonly ui: {
10
+ readonly base: "size-11 shrink-0 cursor-pointer justify-center p-0";
11
+ readonly leading: "static p-0";
12
+ readonly leadingIcon: "size-[1.125rem] text-current";
13
+ readonly value: "sr-only";
14
+ readonly trailing: "hidden";
15
+ readonly content: "z-50 min-w-32";
16
+ };
17
+ };
@@ -0,0 +1,15 @@
1
+ export const appearanceSelect = {
2
+ "aria-label": "Appearance",
3
+ "title": "Appearance",
4
+ "variant": "ghost",
5
+ "color": "neutral",
6
+ "content": { align: "end" },
7
+ "ui": {
8
+ base: "size-11 shrink-0 cursor-pointer justify-center p-0",
9
+ leading: "static p-0",
10
+ leadingIcon: "size-[1.125rem] text-current",
11
+ value: "sr-only",
12
+ trailing: "hidden",
13
+ content: "z-50 min-w-32"
14
+ }
15
+ };
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,202 @@
1
+ <script setup>
2
+ import { computed, ref, useRuntimeConfig } from "#imports";
3
+ import TheHeader from "../components/TheHeader.vue";
4
+ import { useActivityLog } from "../useActivityLog";
5
+ const { public: config } = useRuntimeConfig();
6
+ const { entries, paused, togglePause, clearLog } = useActivityLog(
7
+ (signal) => $fetch("/api/discord/activity", { signal, timeout: 5e3, retry: 0 }),
8
+ import.meta.dev ? config.discord?.wsUrl : void 0
9
+ );
10
+ const filter = ref("all");
11
+ const filtered = computed(() => {
12
+ const list = filter.value === "all" ? entries.value : filter.value === "error" ? entries.value.filter((e) => e.status === "error") : entries.value.filter((e) => e.type === filter.value);
13
+ return list.toReversed();
14
+ });
15
+ const stats = computed(() => {
16
+ const total = entries.value.length;
17
+ const errors = entries.value.filter((e) => e.status === "error").length;
18
+ const commands = entries.value.filter((e) => e.type === "command").length;
19
+ const contextMenus = entries.value.filter((e) => e.type === "context-menu").length;
20
+ const avgDuration = total > 0 ? Math.round(entries.value.reduce((sum, e) => sum + (e.duration ?? 0), 0) / total) : 0;
21
+ return { total, errors, commands, contextMenus, avgDuration };
22
+ });
23
+ const typeIcon = {
24
+ "command": "/",
25
+ "context-menu": "\u2261",
26
+ "autocomplete": "\u2026",
27
+ "error": "!",
28
+ "listener": "\u26A1"
29
+ };
30
+ const typeColor = {
31
+ "command": "text-[#5865F2]",
32
+ "context-menu": "text-[#00DC82]",
33
+ "autocomplete": "text-muted",
34
+ "error": "text-red-500",
35
+ "listener": "text-amber-500"
36
+ };
37
+ function formatTime(ts) {
38
+ return new Date(ts).toLocaleTimeString("en-US", { hour12: false, hour: "2-digit", minute: "2-digit", second: "2-digit" });
39
+ }
40
+ const filters = [
41
+ { key: "all", label: "All" },
42
+ { key: "command", label: "Commands" },
43
+ { key: "context-menu", label: "Context Menus" },
44
+ { key: "error", label: "Errors" }
45
+ ];
46
+ </script>
47
+
48
+ <template>
49
+ <div class="bg-default min-h-screen">
50
+ <TheHeader />
51
+
52
+ <main id="discord-main" tabindex="-1" class="mx-auto px-6 py-8 max-w-6xl">
53
+ <!-- Title bar -->
54
+ <div class="mb-6 flex items-start justify-between">
55
+ <div>
56
+ <h1 class="text-2xl tracking-tight font-bold">
57
+ Activity Log
58
+ </h1>
59
+ <p class="text-muted text-sm mt-1">
60
+ Live interaction history
61
+ </p>
62
+ </div>
63
+ <div class="flex items-center gap-2">
64
+ <button
65
+ class="cursor-pointer rounded-md border px-3 py-1.5 text-xs font-medium transition-colors"
66
+ :class="paused ? 'border-amber-500/50 text-amber-500 bg-amber-500/5' : 'border-default text-muted hover:text-highlighted hover:bg-elevated'"
67
+ :aria-pressed="paused"
68
+ @click="togglePause"
69
+ >
70
+ {{ paused ? "Resume" : "Pause" }}
71
+ </button>
72
+ <button
73
+ class="cursor-pointer rounded-md border border-default px-3 py-1.5 text-xs font-medium text-muted transition-colors hover:text-highlighted hover:bg-elevated"
74
+ @click="clearLog"
75
+ >
76
+ Clear
77
+ </button>
78
+ </div>
79
+ </div>
80
+
81
+ <!-- Stats row -->
82
+ <div class="mb-6 grid grid-cols-2 sm:grid-cols-5 gap-3">
83
+ <div class="rounded-lg border border-default bg-elevated px-3 py-2">
84
+ <p class="text-dimmed text-[10px] font-medium uppercase tracking-wider">
85
+ Total
86
+ </p>
87
+ <p class="text-xl font-bold text-highlighted tabular-nums">
88
+ {{ stats.total }}
89
+ </p>
90
+ </div>
91
+ <div class="rounded-lg border border-default bg-elevated px-3 py-2">
92
+ <p class="text-dimmed text-[10px] font-medium uppercase tracking-wider">
93
+ Commands
94
+ </p>
95
+ <p class="text-xl font-bold text-[#5865F2] tabular-nums">
96
+ {{ stats.commands }}
97
+ </p>
98
+ </div>
99
+ <div class="rounded-lg border border-default bg-elevated px-3 py-2">
100
+ <p class="text-dimmed text-[10px] font-medium uppercase tracking-wider">
101
+ Context Menus
102
+ </p>
103
+ <p class="text-xl font-bold text-[#00DC82] tabular-nums">
104
+ {{ stats.contextMenus }}
105
+ </p>
106
+ </div>
107
+ <div class="rounded-lg border border-default bg-elevated px-3 py-2">
108
+ <p class="text-dimmed text-[10px] font-medium uppercase tracking-wider">
109
+ Errors
110
+ </p>
111
+ <p class="text-xl font-bold tabular-nums" :class="stats.errors > 0 ? 'text-red-500' : 'text-highlighted'">
112
+ {{ stats.errors }}
113
+ </p>
114
+ </div>
115
+ <div class="rounded-lg border border-default bg-elevated px-3 py-2">
116
+ <p class="text-dimmed text-[10px] font-medium uppercase tracking-wider">
117
+ Avg Duration
118
+ </p>
119
+ <p class="text-xl font-bold text-highlighted tabular-nums">
120
+ {{ stats.avgDuration }}<span class="text-xs text-dimmed font-normal">ms</span>
121
+ </p>
122
+ </div>
123
+ </div>
124
+
125
+ <!-- Filters -->
126
+ <div class="mb-4 flex items-center gap-1">
127
+ <button
128
+ v-for="f in filters"
129
+ :key="f.key"
130
+ class="cursor-pointer rounded-md px-2.5 py-1 text-xs font-medium transition-colors"
131
+ :class="filter === f.key ? 'bg-elevated text-highlighted' : 'text-muted hover:text-highlighted hover:bg-elevated/50'"
132
+ :aria-pressed="filter === f.key"
133
+ @click="filter = f.key"
134
+ >
135
+ {{ f.label }}
136
+ <span v-if="f.key === 'error' && stats.errors > 0" class="ml-1 text-red-500">{{ stats.errors }}</span>
137
+ </button>
138
+ </div>
139
+
140
+ <!-- Log entries -->
141
+ <div class="rounded-lg border border-default overflow-hidden">
142
+ <!-- Header row -->
143
+ <div aria-hidden="true" class="hidden grid-cols-[4rem_minmax(0,1fr)_6rem_4rem_3rem] gap-x-4 border-b border-default bg-elevated px-4 py-2 text-[10px] font-medium uppercase tracking-wider text-dimmed md:grid">
144
+ <span class="w-16">Time</span>
145
+ <span>Event</span>
146
+ <span class="w-24 text-right">User</span>
147
+ <span class="w-16 text-right">Duration</span>
148
+ <span class="w-12 text-right">Status</span>
149
+ </div>
150
+
151
+ <!-- Entries -->
152
+ <div v-if="filtered.length === 0" class="px-4 py-12 text-center text-dimmed text-sm">
153
+ {{ entries.length === 0 ? "No activity yet \u2014 interact with your bot to see events here" : "No matching entries" }}
154
+ </div>
155
+ <ul v-else role="list" class="divide-y divide-default md:max-h-[calc(100vh-24rem)] md:overflow-y-auto">
156
+ <li
157
+ v-for="entry in filtered"
158
+ :key="`${entry.timestamp}/${entry.id}`"
159
+ class="grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-3 gap-y-1.5 px-4 py-3 text-sm transition-colors hover:bg-elevated/50 md:grid-cols-[4rem_minmax(0,1fr)_6rem_4rem_3rem] md:items-center md:gap-x-4 md:py-2"
160
+ :class="entry.status === 'error' ? 'bg-red-500/3' : ''"
161
+ >
162
+ <div class="flex min-w-0 items-start gap-2 md:col-start-2 md:row-start-1 md:items-center">
163
+ <span
164
+ aria-hidden="true"
165
+ class="flex size-5 shrink-0 items-center justify-center rounded bg-elevated text-[10px] font-bold"
166
+ :class="typeColor[entry.type]"
167
+ >{{ typeIcon[entry.type] ?? "?" }}</span>
168
+ <div class="min-w-0 md:flex md:items-baseline md:gap-2">
169
+ <span class="block font-medium wrap-anywhere text-highlighted md:truncate">{{ entry.name }}</span>
170
+ <span v-if="entry.detail" class="block text-xs wrap-anywhere text-error md:truncate">{{ entry.detail }}</span>
171
+ </div>
172
+ </div>
173
+
174
+ <span class="inline-flex items-center justify-end gap-1.5 text-xs text-muted md:col-start-5 md:row-start-1">
175
+ <span
176
+ aria-hidden="true"
177
+ class="inline-block size-2 rounded-full"
178
+ :class="entry.status === 'ok' ? 'bg-emerald-500' : 'bg-red-500'"
179
+ />
180
+ <span class="capitalize md:sr-only">{{ entry.status }}</span>
181
+ </span>
182
+
183
+ <div class="col-span-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-muted md:contents">
184
+ <span class="font-mono text-dimmed tabular-nums md:col-start-1 md:row-start-1">
185
+ <span class="sr-only">Time </span>{{ formatTime(entry.timestamp) }}
186
+ </span>
187
+ <span class="min-w-0 wrap-anywhere md:col-start-3 md:row-start-1 md:truncate md:text-right">
188
+ <span class="sr-only">User </span><span>{{ entry.userName ?? "\u2014" }}</span>
189
+ </span>
190
+ <span
191
+ class="font-mono tabular-nums md:col-start-4 md:row-start-1 md:text-right"
192
+ :class="(entry.duration ?? 0) > 1e3 ? 'text-amber-500' : 'text-dimmed'"
193
+ >
194
+ <span class="sr-only">Duration </span><span>{{ entry.duration != null ? `${entry.duration}ms` : "\u2014" }}</span>
195
+ </span>
196
+ </div>
197
+ </li>
198
+ </ul>
199
+ </div>
200
+ </main>
201
+ </div>
202
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,120 @@
1
+ <script setup>
2
+ import { computed } from "#imports";
3
+ import TheHeader from "../components/TheHeader.vue";
4
+ import { useDashboardCatalog } from "../useDashboardCatalog";
5
+ const showEditorLinks = import.meta.dev;
6
+ const { menus } = useDashboardCatalog();
7
+ const userMenus = computed(() => menus.value.filter((m) => m.type === "user"));
8
+ const messageMenus = computed(() => menus.value.filter((m) => m.type === "message"));
9
+ </script>
10
+
11
+ <template>
12
+ <div class="bg-default min-h-screen">
13
+ <TheHeader />
14
+
15
+ <main id="discord-main" tabindex="-1" class="mx-auto px-6 py-8 max-w-6xl">
16
+ <!-- Title bar -->
17
+ <div class="mb-8">
18
+ <h1 class="text-2xl tracking-tight font-bold">
19
+ Context Menus
20
+ </h1>
21
+ <p class="text-muted text-sm mt-1">
22
+ {{ menus.length }} context menu{{ menus.length === 1 ? "" : "s" }}
23
+ </p>
24
+ </div>
25
+
26
+ <!-- Type filter pills -->
27
+ <div v-if="menus.length > 0" class="mb-6 flex flex-wrap gap-2">
28
+ <UBadge v-if="userMenus.length" color="info" variant="subtle" size="sm">
29
+ {{ userMenus.length }} user
30
+ </UBadge>
31
+ <UBadge v-if="messageMenus.length" color="secondary" variant="subtle" size="sm">
32
+ {{ messageMenus.length }} message
33
+ </UBadge>
34
+ </div>
35
+
36
+ <USeparator class="mb-8" />
37
+
38
+ <!-- User Context Menus -->
39
+ <div v-if="userMenus.length > 0" class="mb-8">
40
+ <h2 class="text-sm font-semibold uppercase tracking-wider text-muted mb-4 flex items-center gap-2">
41
+ <svg class="size-4" viewBox="0 0 20 20" fill="currentColor">
42
+ <path fill-rule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd" />
43
+ </svg>
44
+ User Context Menus
45
+ </h2>
46
+ <p class="text-dimmed text-xs mb-4">
47
+ Right-click a user → Apps → your command
48
+ </p>
49
+ <div class="space-y-3">
50
+ <UCard
51
+ v-for="menu in userMenus"
52
+ :key="JSON.stringify([menu.name, menu.guilds])"
53
+ variant="outline"
54
+ >
55
+ <template #header>
56
+ <div class="flex gap-4 items-center justify-between">
57
+ <div class="flex items-center gap-2.5 min-w-0">
58
+ <span class="text-highlighted text-base font-semibold">{{ menu.name }}</span>
59
+ <UBadge label="user" color="info" variant="subtle" size="xs" />
60
+ <UBadge v-if="menu.guilds" :label="menu.guilds === true ? 'guild' : `${menu.guilds.length} guild(s)`" color="warning" variant="soft" size="xs" />
61
+ </div>
62
+ </div>
63
+ </template>
64
+ <template v-if="showEditorLinks" #footer>
65
+ <a :href="`vscode://file${menu.path}`" class="text-dimmed text-xs font-mono truncate hover:text-highlighted transition-colors">{{ menu.path.split("/discord/context-menus/").pop() }}</a>
66
+ </template>
67
+ </UCard>
68
+ </div>
69
+ </div>
70
+
71
+ <!-- Message Context Menus -->
72
+ <div v-if="messageMenus.length > 0" class="mb-8">
73
+ <h2 class="text-sm font-semibold uppercase tracking-wider text-muted mb-4 flex items-center gap-2">
74
+ <svg class="size-4" viewBox="0 0 20 20" fill="currentColor">
75
+ <path fill-rule="evenodd" d="M18 13V5a2 2 0 00-2-2H4a2 2 0 00-2 2v8a2 2 0 002 2h3l3 3 3-3h3a2 2 0 002-2z" clip-rule="evenodd" />
76
+ </svg>
77
+ Message Context Menus
78
+ </h2>
79
+ <p class="text-dimmed text-xs mb-4">
80
+ Right-click a message → Apps → your command
81
+ </p>
82
+ <div class="space-y-3">
83
+ <UCard
84
+ v-for="menu in messageMenus"
85
+ :key="JSON.stringify([menu.name, menu.guilds])"
86
+ variant="outline"
87
+ >
88
+ <template #header>
89
+ <div class="flex gap-4 items-center justify-between">
90
+ <div class="flex items-center gap-2.5 min-w-0">
91
+ <span class="text-highlighted text-base font-semibold">{{ menu.name }}</span>
92
+ <UBadge label="message" color="secondary" variant="subtle" size="xs" />
93
+ <UBadge v-if="menu.guilds" :label="menu.guilds === true ? 'guild' : `${menu.guilds.length} guild(s)`" color="warning" variant="soft" size="xs" />
94
+ </div>
95
+ </div>
96
+ </template>
97
+ <template v-if="showEditorLinks" #footer>
98
+ <a :href="`vscode://file${menu.path}`" class="text-dimmed text-xs font-mono truncate hover:text-highlighted transition-colors">{{ menu.path.split("/discord/context-menus/").pop() }}</a>
99
+ </template>
100
+ </UCard>
101
+ </div>
102
+ </div>
103
+
104
+ <!-- Empty state -->
105
+ <div v-if="menus.length === 0" class="py-20 text-center flex flex-col items-center justify-center">
106
+ <div class="bg-elevated mb-4 rounded-2xl flex size-16 items-center justify-center">
107
+ <svg class="size-7 text-muted" viewBox="0 0 20 20" fill="currentColor">
108
+ <path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 011 1v2a1 1 0 01-1 1H4a1 1 0 01-1-1V5zm0 4a1 1 0 011-1h12a1 1 0 011 1v2a1 1 0 01-1 1H4a1 1 0 01-1-1V9zm0 4a1 1 0 011-1h6a1 1 0 011 1v2a1 1 0 01-1 1H4a1 1 0 01-1-1v-2z" clip-rule="evenodd" />
109
+ </svg>
110
+ </div>
111
+ <h3 class="text-lg font-semibold">
112
+ No context menus yet
113
+ </h3>
114
+ <p class="text-muted text-sm mt-1 max-w-sm">
115
+ Create a file in <code class="bg-elevated text-xs px-1.5 py-0.5 rounded">discord/context-menus/</code> to get started.
116
+ </p>
117
+ </div>
118
+ </main>
119
+ </div>
120
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;