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.
- package/README.md +249 -171
- package/dist/module.d.mts +146 -10
- package/dist/module.json +3 -3
- package/dist/module.mjs +1077 -348
- package/dist/runtime/acknowledgement.d.ts +11 -0
- package/dist/runtime/acknowledgement.js +156 -0
- package/dist/runtime/client/chat-theme.css +52 -0
- package/dist/runtime/client/components/ChatAvatar.d.vue.ts +6 -0
- package/dist/runtime/client/components/ChatAvatar.vue +11 -0
- package/dist/runtime/client/components/ChatAvatar.vue.d.ts +6 -0
- package/dist/runtime/client/components/CommandPicker.d.vue.ts +24 -0
- package/dist/runtime/client/components/CommandPicker.vue +67 -0
- package/dist/runtime/client/components/CommandPicker.vue.d.ts +24 -0
- package/dist/runtime/client/components/CommandReference.d.vue.ts +20 -0
- package/dist/runtime/client/components/CommandReference.vue +21 -0
- package/dist/runtime/client/components/CommandReference.vue.d.ts +20 -0
- package/dist/runtime/client/components/CommandTestBar.d.vue.ts +60 -0
- package/dist/runtime/client/components/CommandTestBar.vue +332 -0
- package/dist/runtime/client/components/CommandTestBar.vue.d.ts +60 -0
- package/dist/runtime/client/components/CommandTranscript.d.vue.ts +39 -0
- package/dist/runtime/client/components/CommandTranscript.vue +147 -0
- package/dist/runtime/client/components/CommandTranscript.vue.d.ts +39 -0
- package/dist/runtime/client/components/ProjectLogo.d.vue.ts +3 -0
- package/dist/runtime/client/components/ProjectLogo.vue +31 -0
- package/dist/runtime/client/components/ProjectLogo.vue.d.ts +3 -0
- package/dist/runtime/client/components/ReferenceContent.d.ts +26 -0
- package/dist/runtime/client/components/ReferenceContent.js +73 -0
- package/dist/runtime/client/components/TheHeader.d.vue.ts +3 -0
- package/dist/runtime/client/components/TheHeader.vue +53 -16
- package/dist/runtime/client/components/TheHeader.vue.d.ts +2 -2
- package/dist/runtime/client/components/appearance-select.d.ts +17 -0
- package/dist/runtime/client/components/appearance-select.js +15 -0
- package/dist/runtime/client/pages/activity.d.vue.ts +3 -0
- package/dist/runtime/client/pages/activity.vue +202 -0
- package/dist/runtime/client/pages/activity.vue.d.ts +3 -0
- package/dist/runtime/client/pages/context-menus.d.vue.ts +3 -0
- package/dist/runtime/client/pages/context-menus.vue +120 -0
- package/dist/runtime/client/pages/context-menus.vue.d.ts +3 -0
- package/dist/runtime/client/pages/listeners.d.vue.ts +3 -0
- package/dist/runtime/client/pages/listeners.vue +68 -0
- package/dist/runtime/client/pages/listeners.vue.d.ts +3 -0
- package/dist/runtime/client/pages/overview.d.vue.ts +3 -0
- package/dist/runtime/client/pages/overview.vue +280 -0
- package/dist/runtime/client/pages/overview.vue.d.ts +3 -0
- package/dist/runtime/client/pages/slash-commands.d.vue.ts +3 -0
- package/dist/runtime/client/pages/slash-commands.vue +185 -359
- package/dist/runtime/client/pages/slash-commands.vue.d.ts +2 -3
- package/dist/runtime/client/reference.css +46 -0
- package/dist/runtime/client/style.css +4 -1
- package/dist/runtime/client/useActivityLog.d.ts +7 -0
- package/dist/runtime/client/useActivityLog.js +76 -0
- package/dist/runtime/client/useCommandRegistry.d.ts +7 -0
- package/dist/runtime/client/useCommandRegistry.js +34 -0
- package/dist/runtime/client/useDashboardCatalog.d.ts +5 -0
- package/dist/runtime/client/useDashboardCatalog.js +9 -0
- package/dist/runtime/client/useDiscordCommandReference.d.ts +2 -0
- package/dist/runtime/client/useDiscordCommandReference.js +6 -0
- package/dist/runtime/dashboard/auth.d.ts +4 -0
- package/dist/runtime/dashboard/auth.js +55 -0
- package/dist/runtime/dashboard/oauth.d.ts +17 -0
- package/dist/runtime/dashboard/oauth.js +172 -0
- package/dist/runtime/dashboard/origin.d.ts +3 -0
- package/dist/runtime/dashboard/origin.js +15 -0
- package/dist/runtime/dashboard/permissions.d.ts +4 -0
- package/dist/runtime/dashboard/permissions.js +84 -0
- package/dist/runtime/dashboard/signin.d.ts +3 -0
- package/dist/runtime/dashboard/signin.js +42 -0
- package/dist/runtime/diagnostics.d.ts +4 -0
- package/dist/runtime/diagnostics.js +24 -0
- package/dist/runtime/discordInvocation.d.ts +14 -0
- package/dist/runtime/discordInvocation.js +28 -0
- package/dist/runtime/middleware.d.ts +1 -0
- package/dist/runtime/middleware.js +12 -0
- package/dist/runtime/reference/access.d.ts +6 -0
- package/dist/runtime/reference/access.js +143 -0
- package/dist/runtime/reference/catalog.d.ts +2 -0
- package/dist/runtime/reference/catalog.js +9 -0
- package/dist/runtime/reference/document.d.ts +2 -0
- package/dist/runtime/reference/document.js +22 -0
- package/dist/runtime/reference/hosted.d.ts +2 -0
- package/dist/runtime/reference/hosted.js +16 -0
- package/dist/runtime/reference/oauth.d.ts +2 -0
- package/dist/runtime/reference/oauth.js +4 -0
- package/dist/runtime/registration.d.ts +65 -0
- package/dist/runtime/registration.js +354 -0
- package/dist/runtime/server/api/discord/activity.get.d.ts +2 -0
- package/dist/runtime/server/api/discord/activity.get.js +6 -0
- package/dist/runtime/server/api/discord/catalog.get.d.ts +2 -0
- package/dist/runtime/server/api/discord/catalog.get.js +3 -0
- package/dist/runtime/server/api/discord/slash-command/autocomplete.post.d.ts +2 -0
- package/dist/runtime/server/api/discord/slash-command/autocomplete.post.js +14 -0
- package/dist/runtime/server/api/discord/slash-command/register.post.d.ts +1 -1
- package/dist/runtime/server/api/discord/slash-command/register.post.js +1 -1
- package/dist/runtime/server/api/discord/slash-command/remote-all.get.d.ts +1 -1
- package/dist/runtime/server/api/discord/slash-command/remote-diff.post.d.ts +1 -238
- package/dist/runtime/server/api/discord/slash-command/remote-diff.post.js +3 -1
- package/dist/runtime/server/api/discord/slash-command/test.post.d.ts +20 -0
- package/dist/runtime/server/api/discord/slash-command/test.post.js +19 -0
- package/dist/runtime/server/plugins/discord.js +95 -31
- package/dist/runtime/server/utils/client.d.ts +59 -246
- package/dist/runtime/server/utils/client.js +413 -451
- package/dist/runtime/server/utils/defineContextMenu.d.ts +49 -0
- package/dist/runtime/server/utils/defineContextMenu.js +12 -0
- package/dist/runtime/server/utils/defineListener.d.ts +24 -0
- package/dist/runtime/server/utils/defineListener.js +7 -0
- package/dist/runtime/server/utils/defineMiddleware.d.ts +29 -0
- package/dist/runtime/server/utils/defineMiddleware.js +24 -0
- package/dist/runtime/server/utils/describeCommand.d.ts +2 -0
- package/dist/runtime/server/utils/describeOption.d.ts +1 -1
- package/dist/runtime/server/utils/messageSender.d.ts +37 -0
- package/dist/runtime/server/utils/messageSender.js +149 -0
- package/dist/runtime/server/utils/middleware/cooldown.d.ts +1 -0
- package/dist/runtime/server/utils/middleware/cooldown.js +39 -0
- package/dist/runtime/server/utils/middleware/guildOnly.d.ts +1 -0
- package/dist/runtime/server/utils/middleware/guildOnly.js +6 -0
- package/dist/runtime/server/utils/middleware/ownerOnly.d.ts +1 -0
- package/dist/runtime/server/utils/middleware/ownerOnly.js +10 -0
- package/dist/runtime/server/utils/middleware/requireRole.d.ts +1 -0
- package/dist/runtime/server/utils/middleware/requireRole.js +15 -0
- package/dist/runtime/server/utils/reply.d.ts +13 -3
- package/dist/runtime/server/utils/reply.js +111 -162
- package/dist/runtime/server/utils/simulateInteraction.d.ts +20 -0
- package/dist/runtime/server/utils/simulateInteraction.js +127 -0
- package/dist/runtime/server/utils/useTextChannel.d.ts +56 -0
- package/dist/runtime/server/utils/useTextChannel.js +105 -0
- package/dist/types.d.mts +11 -1
- package/dist/types.d.ts +11 -1
- package/package.json +62 -44
- package/dist/runtime/client/components/TheHeader.css +0 -1
- package/dist/runtime/client/pages/slash-commands.css +0 -1
- package/dist/runtime/client/uno.config.d.ts +0 -2
- package/dist/runtime/client/uno.config.js +0 -10
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useWebSocket } from "@vueuse/core";
|
|
2
|
+
import { computed, ref, useFetch } from "#imports";
|
|
3
|
+
import CommandTestBar from "../components/CommandTestBar.vue";
|
|
5
4
|
import TheHeader from "../components/TheHeader.vue";
|
|
6
|
-
import "../
|
|
7
|
-
import "./slash-commands.css";
|
|
5
|
+
import { useCommandRegistry } from "../useCommandRegistry";
|
|
8
6
|
var ApplicationCommandOptionType = /* @__PURE__ */ ((ApplicationCommandOptionType2) => {
|
|
9
7
|
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Subcommand"] = 1] = "Subcommand";
|
|
10
8
|
ApplicationCommandOptionType2[ApplicationCommandOptionType2["SubcommandGroup"] = 2] = "SubcommandGroup";
|
|
@@ -19,423 +17,251 @@ var ApplicationCommandOptionType = /* @__PURE__ */ ((ApplicationCommandOptionTyp
|
|
|
19
17
|
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Attachment"] = 11] = "Attachment";
|
|
20
18
|
return ApplicationCommandOptionType2;
|
|
21
19
|
})(ApplicationCommandOptionType || {});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return "user";
|
|
34
|
-
case 7 /* Channel */:
|
|
35
|
-
return "channel";
|
|
36
|
-
case 8 /* Role */:
|
|
37
|
-
return "role";
|
|
38
|
-
case 9 /* Mentionable */:
|
|
39
|
-
return "mention";
|
|
40
|
-
case 11 /* Attachment */:
|
|
41
|
-
return "file";
|
|
42
|
-
default:
|
|
43
|
-
return "unknown";
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function getOptionTypeColor(type) {
|
|
47
|
-
switch (type) {
|
|
48
|
-
case 3 /* String */:
|
|
49
|
-
return "primary";
|
|
50
|
-
case 4 /* Integer */:
|
|
51
|
-
case 10 /* Number */:
|
|
52
|
-
return "info";
|
|
53
|
-
case 5 /* Boolean */:
|
|
54
|
-
return "success";
|
|
55
|
-
case 6 /* User */:
|
|
56
|
-
case 8 /* Role */:
|
|
57
|
-
case 9 /* Mentionable */:
|
|
58
|
-
return "secondary";
|
|
59
|
-
case 7 /* Channel */:
|
|
60
|
-
return "warning";
|
|
61
|
-
case 11 /* Attachment */:
|
|
62
|
-
return "neutral";
|
|
63
|
-
default:
|
|
64
|
-
return "neutral";
|
|
65
|
-
}
|
|
66
|
-
}
|
|
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
|
+
};
|
|
67
31
|
function getRemoteId(command) {
|
|
68
|
-
if ("remote" in command && command.remote?.id)
|
|
32
|
+
if ("remote" in command && command.remote?.id)
|
|
69
33
|
return command.remote.id;
|
|
70
|
-
}
|
|
71
|
-
return void 0;
|
|
72
34
|
}
|
|
73
|
-
const commands =
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
method: "post",
|
|
81
|
-
immediate: import.meta.dev
|
|
82
|
-
}
|
|
83
|
-
);
|
|
35
|
+
const { commands, diff, status, refresh: refreshDiff } = useCommandRegistry();
|
|
36
|
+
const { data: session, status: sessionStatus } = useFetch("/__discord-auth/session", {
|
|
37
|
+
server: false,
|
|
38
|
+
immediate: !import.meta.dev
|
|
39
|
+
});
|
|
40
|
+
const canManage = computed(() => import.meta.dev || sessionStatus.value === "success" && session.value?.access === "manage");
|
|
84
41
|
const commandsWithStatus = computed(() => {
|
|
85
42
|
if (!diff.value) {
|
|
86
43
|
return commands.value.map((cmd) => ({
|
|
87
44
|
...cmd,
|
|
88
|
-
status: "
|
|
45
|
+
status: "unknown",
|
|
46
|
+
scope: ""
|
|
89
47
|
}));
|
|
90
48
|
}
|
|
91
49
|
return [
|
|
92
|
-
...diff.value.conflict.map((cmd) => ({
|
|
93
|
-
|
|
94
|
-
status: "conflict"
|
|
95
|
-
})),
|
|
96
|
-
...diff.value.added.map((cmd) => ({
|
|
97
|
-
...cmd,
|
|
98
|
-
status: "added"
|
|
99
|
-
})),
|
|
50
|
+
...diff.value.conflict.map((cmd) => ({ ...cmd, status: "conflict" })),
|
|
51
|
+
...diff.value.added.map((cmd) => ({ ...cmd, status: "added" })),
|
|
100
52
|
...diff.value.removed.map((cmd) => ({
|
|
101
53
|
name: cmd.name,
|
|
102
54
|
description: cmd.description,
|
|
103
|
-
path: "
|
|
55
|
+
path: "",
|
|
56
|
+
scope: cmd.scope,
|
|
104
57
|
options: cmd.options ?? [],
|
|
105
58
|
status: "removed",
|
|
106
59
|
remote: cmd
|
|
107
60
|
})),
|
|
108
|
-
...diff.value.changed.map(({ remote, local }) => ({
|
|
109
|
-
|
|
110
|
-
status: "changed",
|
|
111
|
-
remote
|
|
112
|
-
})),
|
|
113
|
-
...diff.value.synced.map(({ remote, local }) => ({
|
|
114
|
-
...local,
|
|
115
|
-
status: "synced",
|
|
116
|
-
remote
|
|
117
|
-
}))
|
|
61
|
+
...diff.value.changed.map(({ remote, local }) => ({ ...local, status: "changed", remote })),
|
|
62
|
+
...diff.value.synced.map(({ remote, local }) => ({ ...local, status: "synced", remote }))
|
|
118
63
|
];
|
|
119
64
|
});
|
|
120
|
-
const
|
|
65
|
+
const sortedCommands = computed(
|
|
66
|
+
() => commandsWithStatus.value.toSorted((a, b) => a.name.localeCompare(b.name))
|
|
67
|
+
);
|
|
68
|
+
const allSynced = computed(() => diff.value && !diff.value.menuChanges && commandsWithStatus.value.every((cmd) => cmd.status === "synced"));
|
|
121
69
|
const stats = computed(() => commandsWithStatus.value.reduce((acc, cmd) => {
|
|
122
|
-
|
|
123
|
-
acc.added++;
|
|
124
|
-
else if (cmd.status === "removed")
|
|
125
|
-
acc.removed++;
|
|
126
|
-
else if (cmd.status === "changed")
|
|
127
|
-
acc.changed++;
|
|
128
|
-
else if (cmd.status === "synced")
|
|
129
|
-
acc.synced++;
|
|
130
|
-
else if (cmd.status === "conflict")
|
|
131
|
-
acc.conflict++;
|
|
70
|
+
acc[cmd.status]++;
|
|
132
71
|
return acc;
|
|
133
|
-
}, { added: 0, removed: 0, changed: 0, synced: 0, conflict: 0 }));
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
if (import.meta.dev && runtimeConfig.public.discord?.wsUrl) {
|
|
137
|
-
if (!("WebSocket" in window)) {
|
|
138
|
-
console.warn("Could not enable hot reload, your browser does not support WebSocket");
|
|
139
|
-
} else {
|
|
140
|
-
ws = useWebSocket(runtimeConfig.public.discord.wsUrl, {
|
|
141
|
-
autoReconnect: true,
|
|
142
|
-
onConnected: (ws2) => {
|
|
143
|
-
console.log("WebSocket connection established for slash command hot reload");
|
|
144
|
-
ws2.send(JSON.stringify({ event: "full-update" }));
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
72
|
+
}, { added: 0, removed: 0, changed: 0, synced: 0, conflict: 0, unknown: 0 }));
|
|
73
|
+
const showEditorLinks = import.meta.dev;
|
|
74
|
+
const syncFeedback = ref();
|
|
149
75
|
const pendingSync = ref(false);
|
|
150
76
|
async function syncCommands() {
|
|
77
|
+
if (!canManage.value || pendingSync.value)
|
|
78
|
+
return;
|
|
79
|
+
pendingSync.value = true;
|
|
80
|
+
syncFeedback.value = void 0;
|
|
151
81
|
try {
|
|
152
|
-
|
|
153
|
-
|
|
82
|
+
const results = await $fetch("/api/discord/slash-command/register", { method: "POST" });
|
|
83
|
+
const failed = results.filter((result) => result.error);
|
|
84
|
+
syncFeedback.value = failed.length ? { title: "Command sync incomplete", detail: failed.map((result) => `${result.scope}: ${result.error}`).join(" \xB7 "), failed: true } : { title: "Commands synced" };
|
|
154
85
|
await refreshDiff();
|
|
155
|
-
ws?.send(JSON.stringify({ event: "full-update" }));
|
|
156
86
|
} catch (error) {
|
|
157
|
-
|
|
87
|
+
syncFeedback.value = { title: "Sync failed", detail: String(error), failed: true };
|
|
158
88
|
} finally {
|
|
159
89
|
pendingSync.value = false;
|
|
160
90
|
}
|
|
161
91
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
} else {
|
|
170
|
-
ws?.send(JSON.stringify({ event: "full-update" }));
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
const statusColors = {
|
|
174
|
-
synced: "primary",
|
|
175
|
-
added: "secondary",
|
|
176
|
-
changed: "warning",
|
|
177
|
-
removed: "neutral",
|
|
178
|
-
conflict: "error"
|
|
179
|
-
};
|
|
180
|
-
const statusClasses = {
|
|
181
|
-
synced: "",
|
|
182
|
-
added: "ring-0 border border-dashed border-[var(--ui-secondary)]/50 divide-[var(--ui-secondary)]/50 divide-dashed",
|
|
183
|
-
changed: "ring-0 border border-dashed border-[var(--ui-warning)]/50 divide-[var(--ui-warning)]/50 divide-dashed",
|
|
184
|
-
removed: "ring-0 border border-dashed border-[var(--ui-neutral)]/50 divide-[var(--ui-neutral)]/50 divide-dashed",
|
|
185
|
-
conflict: "ring-0 border border-dashed border-[var(--ui-error)]/50 divide-[var(--ui-error)]/50 divide-dashed"
|
|
92
|
+
const statusMeta = {
|
|
93
|
+
unknown: { color: "neutral", classes: "" },
|
|
94
|
+
synced: { color: "primary", classes: "" },
|
|
95
|
+
added: { color: "success", classes: "border-dashed border-emerald-500/40" },
|
|
96
|
+
changed: { color: "warning", classes: "border-dashed border-amber-500/40" },
|
|
97
|
+
removed: { color: "neutral", classes: "border-dashed border-neutral-400/40 opacity-60" },
|
|
98
|
+
conflict: { color: "error", classes: "border-dashed border-red-500/40" }
|
|
186
99
|
};
|
|
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
|
+
}
|
|
187
114
|
</script>
|
|
188
115
|
|
|
189
116
|
<template>
|
|
190
|
-
<
|
|
117
|
+
<div class="bg-default min-h-screen">
|
|
191
118
|
<TheHeader />
|
|
192
|
-
<div class="mx-auto mb-16 px-6 container">
|
|
193
|
-
<!-- Title Section -->
|
|
194
|
-
<div class="my-6">
|
|
195
|
-
<h1 class="text-3xl text-gray-900 font-bold mb-2 dark:text-white">
|
|
196
|
-
Discord Slash Commands
|
|
197
|
-
</h1>
|
|
198
|
-
<p class="text-sm text-gray-600 dark:text-gray-400">
|
|
199
|
-
Manage and view your registered Discord slash commands
|
|
200
|
-
</p>
|
|
201
|
-
</div>
|
|
202
119
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
v-if="stats.conflict > 0"
|
|
214
|
-
:label="`${stats.conflict} conflict${stats.conflict === 1 ? '' : 's'}`"
|
|
215
|
-
variant="outline"
|
|
216
|
-
color="error"
|
|
217
|
-
size="lg"
|
|
218
|
-
/>
|
|
219
|
-
<UBadge
|
|
220
|
-
v-if="stats.added > 0"
|
|
221
|
-
:label="`${stats.added} added`"
|
|
222
|
-
variant="outline"
|
|
223
|
-
color="secondary"
|
|
224
|
-
size="lg"
|
|
225
|
-
/>
|
|
226
|
-
<UBadge
|
|
227
|
-
v-if="stats.changed > 0"
|
|
228
|
-
:label="`${stats.changed} changed`"
|
|
229
|
-
variant="outline"
|
|
230
|
-
color="warning"
|
|
231
|
-
size="lg"
|
|
232
|
-
/>
|
|
233
|
-
<UBadge
|
|
234
|
-
v-if="stats.removed > 0"
|
|
235
|
-
:label="`${stats.removed} removed`"
|
|
236
|
-
variant="outline"
|
|
237
|
-
color="neutral"
|
|
238
|
-
size="lg"
|
|
239
|
-
/>
|
|
120
|
+
<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>
|
|
240
130
|
</div>
|
|
241
|
-
|
|
242
131
|
<UButton
|
|
243
|
-
v-if="!allSynced"
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
132
|
+
v-if="canManage && !allSynced"
|
|
133
|
+
label="Sync to Discord"
|
|
134
|
+
color="primary"
|
|
135
|
+
variant="solid"
|
|
136
|
+
size="sm"
|
|
137
|
+
class="cursor-pointer"
|
|
138
|
+
:loading="pendingSync"
|
|
248
139
|
:disabled="stats.conflict > 0"
|
|
249
|
-
:title="stats.conflict > 0 ? 'Resolve conflicts before syncing' : 'Register out of sync commands'"
|
|
250
|
-
:ui="{ leadingIcon: pendingSync ? 'animate-spin' : '' }"
|
|
251
140
|
@click="syncCommands"
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<div role="status" aria-atomic="true">
|
|
145
|
+
<p v-if="syncFeedback" class="mb-3 border-s-2 ps-3 text-sm" :class="syncFeedback.failed ? 'border-error' : 'border-success'">
|
|
146
|
+
<strong class="text-highlighted">{{ syncFeedback.title }}</strong>
|
|
147
|
+
<span v-if="syncFeedback.detail" class="block wrap-anywhere text-toned">{{ syncFeedback.detail }}</span>
|
|
148
|
+
</p>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<!-- Status pills -->
|
|
152
|
+
<p v-if="!diff || diff.menuChanges" role="status" class="mb-3 text-sm text-muted">
|
|
153
|
+
{{ !diff ? status === "pending" ? "Checking Discord\u2026" : "Remote registration status is unknown." : "Context menu changes are ready to sync." }}
|
|
154
|
+
</p>
|
|
155
|
+
<div v-if="!allSynced" class="mb-6 flex flex-wrap gap-2">
|
|
156
|
+
<template v-for="(count, key) in stats" :key="key">
|
|
157
|
+
<UBadge
|
|
158
|
+
v-if="count > 0"
|
|
159
|
+
:color="statusMeta[key].color"
|
|
160
|
+
variant="subtle"
|
|
161
|
+
size="sm"
|
|
162
|
+
>
|
|
163
|
+
{{ count }} {{ key }}
|
|
164
|
+
</UBadge>
|
|
165
|
+
</template>
|
|
255
166
|
</div>
|
|
256
167
|
|
|
257
|
-
|
|
258
|
-
|
|
168
|
+
<USeparator class="mb-8" />
|
|
169
|
+
|
|
170
|
+
<!-- Commands -->
|
|
171
|
+
<div v-if="sortedCommands.length > 0" class="space-y-3">
|
|
259
172
|
<UCard
|
|
260
|
-
v-for="command in
|
|
261
|
-
:key="command.name"
|
|
262
|
-
|
|
263
|
-
:class="
|
|
264
|
-
:ui="{ body: '
|
|
173
|
+
v-for="command in sortedCommands"
|
|
174
|
+
:key="command.scope + command.name"
|
|
175
|
+
variant="outline"
|
|
176
|
+
:class="statusMeta[command.status].classes"
|
|
177
|
+
:ui="command.options.length === 0 ? { body: 'hidden' } : {}"
|
|
265
178
|
>
|
|
266
179
|
<template #header>
|
|
267
|
-
<div class="flex items-
|
|
268
|
-
<div class="flex
|
|
269
|
-
<
|
|
270
|
-
|
|
271
|
-
<
|
|
272
|
-
class="text-lg text-gray-700 font-semibold dark:text-gray-200"
|
|
273
|
-
:class="command.status === 'conflict' && 'text-[var(--ui-error)]!'"
|
|
274
|
-
>
|
|
275
|
-
/{{ command.name }}
|
|
276
|
-
</h3>
|
|
277
|
-
<p class="text-sm text-gray-600 dark:text-gray-400">
|
|
278
|
-
{{ command.description }}
|
|
279
|
-
</p>
|
|
280
|
-
<UBadge
|
|
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
|
-
/>
|
|
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>
|
|
287
185
|
<UBadge
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
size="sm"
|
|
186
|
+
:color="statusMeta[command.status].color"
|
|
187
|
+
variant="subtle"
|
|
188
|
+
size="xs"
|
|
189
|
+
:label="command.status"
|
|
293
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}`" />
|
|
294
195
|
</div>
|
|
196
|
+
<p class="text-muted text-sm mt-1">
|
|
197
|
+
{{ command.description }}
|
|
198
|
+
</p>
|
|
295
199
|
</div>
|
|
296
200
|
|
|
297
|
-
<div class="flex gap-
|
|
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
|
+
/>
|
|
298
207
|
<UBadge
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
variant="soft"
|
|
208
|
+
v-if="getRemoteId(command)"
|
|
209
|
+
label="registered" color="success" variant="soft" size="xs"
|
|
210
|
+
:title="`ID: ${getRemoteId(command)}`"
|
|
303
211
|
/>
|
|
304
212
|
</div>
|
|
305
213
|
</div>
|
|
306
214
|
</template>
|
|
307
215
|
|
|
308
|
-
<!--
|
|
309
|
-
<div v-if="command.options.length > 0" class="
|
|
310
|
-
<
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
v-if="option.required"
|
|
332
|
-
label="required"
|
|
333
|
-
variant="soft"
|
|
334
|
-
color="error"
|
|
335
|
-
size="sm"
|
|
336
|
-
/>
|
|
337
|
-
<UBadge
|
|
338
|
-
v-if="option.hasAutocomplete"
|
|
339
|
-
label="autocomplete"
|
|
340
|
-
variant="soft"
|
|
341
|
-
color="info"
|
|
342
|
-
size="sm"
|
|
343
|
-
/>
|
|
344
|
-
<!-- Restriction badges -->
|
|
345
|
-
<UBadge
|
|
346
|
-
v-if="'min' in option && option.min !== void 0"
|
|
347
|
-
:label="`min: ${option.min}`"
|
|
348
|
-
variant="outline"
|
|
349
|
-
color="neutral"
|
|
350
|
-
size="sm"
|
|
351
|
-
/>
|
|
352
|
-
<UBadge
|
|
353
|
-
v-if="'max' in option && option.max !== void 0"
|
|
354
|
-
:label="`max: ${option.max}`"
|
|
355
|
-
variant="outline"
|
|
356
|
-
color="neutral"
|
|
357
|
-
size="sm"
|
|
358
|
-
/>
|
|
359
|
-
<UBadge
|
|
360
|
-
v-if="'minLength' in option && option.minLength !== void 0"
|
|
361
|
-
:label="`min: ${option.minLength}`"
|
|
362
|
-
variant="outline"
|
|
363
|
-
color="neutral"
|
|
364
|
-
size="sm"
|
|
365
|
-
/>
|
|
366
|
-
<UBadge
|
|
367
|
-
v-if="'maxLength' in option && option.maxLength !== void 0"
|
|
368
|
-
:label="`max: ${option.maxLength}`"
|
|
369
|
-
variant="outline"
|
|
370
|
-
color="neutral"
|
|
371
|
-
size="sm"
|
|
372
|
-
/>
|
|
373
|
-
<!-- Choices dropdown -->
|
|
374
|
-
<UDropdownMenu
|
|
375
|
-
v-if="'choices' in option && option.choices && option.choices.length > 0"
|
|
376
|
-
:items="option.choices.map((choice) => ({
|
|
377
|
-
label: choice.name,
|
|
378
|
-
value: typeof choice.value === 'string' ? `\'${choice.value}\'` : choice.value
|
|
379
|
-
}))"
|
|
380
|
-
:popper="{ placement: 'bottom-start' }"
|
|
381
|
-
:ui="{ itemTrailing: 'text-sm text-gray-500 dark:text-gray-400' }"
|
|
382
|
-
>
|
|
383
|
-
<UBadge
|
|
384
|
-
v-if="'choices' in option && option.choices && option.choices.length > 0"
|
|
385
|
-
:label="`${option.choices.length} choices`"
|
|
386
|
-
variant="outline"
|
|
387
|
-
color="info"
|
|
388
|
-
size="sm"
|
|
389
|
-
class="hover:cursor-pointer"
|
|
390
|
-
/>
|
|
391
|
-
<template #item-trailing="{ item: { value } }">
|
|
392
|
-
{{ value }}
|
|
393
|
-
</template>
|
|
394
|
-
</UDropdownMenu>
|
|
395
|
-
</div>
|
|
396
|
-
|
|
397
|
-
<p class="text-sm text-gray-600 dark:text-gray-400">
|
|
398
|
-
{{ option.description }}
|
|
399
|
-
</p>
|
|
400
|
-
</UCard>
|
|
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>
|
|
226
|
+
<UBadge
|
|
227
|
+
:label="typeConfig[option.type]?.label ?? '?'"
|
|
228
|
+
:color="typeConfig[option.type]?.color ?? 'neutral'"
|
|
229
|
+
variant="subtle" size="xs"
|
|
230
|
+
/>
|
|
231
|
+
<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"
|
|
238
|
+
/>
|
|
401
239
|
</div>
|
|
402
240
|
</div>
|
|
403
|
-
<div v-else class="mt-4">
|
|
404
|
-
<p class="text-sm text-gray-500 dark:text-gray-400">
|
|
405
|
-
No parameters defined for this command
|
|
406
|
-
</p>
|
|
407
|
-
</div>
|
|
408
241
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
<
|
|
413
|
-
<UIcon name="i-heroicons-folder" class="h-4 w-4" />
|
|
414
|
-
<span>{{ command.path }}</span>
|
|
415
|
-
</div>
|
|
416
|
-
<div v-if="getRemoteId(command)" class="text-xs text-gray-500 flex gap-2 items-center dark:text-gray-400">
|
|
417
|
-
<UIcon name="i-heroicons-cloud" class="h-4 w-4" />
|
|
418
|
-
<span>Command ID: {{ getRemoteId(command) }}</span>
|
|
419
|
-
</div>
|
|
242
|
+
<template v-if="showEditorLinks && command.path || getRemoteId(command)" #footer>
|
|
243
|
+
<div class="text-dimmed text-xs flex items-center justify-between">
|
|
244
|
+
<a v-if="showEditorLinks && command.path" :href="`vscode://file${command.path}`" class="font-mono truncate hover:text-highlighted transition-colors">{{ command.path.split("/discord/commands/").pop() }}</a>
|
|
245
|
+
<span v-if="getRemoteId(command)" class="font-mono shrink-0">{{ getRemoteId(command) }}</span>
|
|
420
246
|
</div>
|
|
421
247
|
</template>
|
|
422
248
|
</UCard>
|
|
423
249
|
</div>
|
|
424
250
|
|
|
425
|
-
<!--
|
|
426
|
-
<
|
|
427
|
-
<div class="
|
|
428
|
-
<
|
|
429
|
-
<div>
|
|
430
|
-
<h3 class="text-lg text-gray-900 font-medium mb-2 dark:text-white">
|
|
431
|
-
No commands found
|
|
432
|
-
</h3>
|
|
433
|
-
<p class="text-gray-600 dark:text-gray-400">
|
|
434
|
-
Create your first slash command to get started
|
|
435
|
-
</p>
|
|
436
|
-
</div>
|
|
251
|
+
<!-- Empty state -->
|
|
252
|
+
<div v-else class="py-20 text-center flex flex-col items-center justify-center">
|
|
253
|
+
<div class="bg-elevated mb-4 rounded-2xl flex size-16 items-center justify-center">
|
|
254
|
+
<span class="text-2xl">/</span>
|
|
437
255
|
</div>
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
256
|
+
<h3 class="text-lg font-semibold">
|
|
257
|
+
No commands yet
|
|
258
|
+
</h3>
|
|
259
|
+
<p class="text-muted text-sm mt-1 max-w-sm">
|
|
260
|
+
Create a file in <code class="bg-elevated text-xs px-1.5 py-0.5 rounded">discord/commands/</code> to get started.
|
|
261
|
+
</p>
|
|
262
|
+
</div>
|
|
263
|
+
</main>
|
|
264
|
+
|
|
265
|
+
<CommandTestBar v-if="canManage" :commands="commands" />
|
|
266
|
+
</div>
|
|
441
267
|
</template>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
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;
|
|
4
3
|
export default _default;
|