Add public bot command catalog
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
let oauthBusy = false;
|
||||
let oauthError = '';
|
||||
let botCommands: Array<{ id: string; name: string; description: string; permission_level: string; aliases: string[]; tags: string[]; cooldown_seconds: number; cooldown_scope: string; response_template: string; error_template: string | null; enabled: boolean }> = [];
|
||||
let publicBotCommands: Array<{ id: string; name: string; description: string; permission_level: string; aliases: string[]; tags: string[] }> = [];
|
||||
let botCommandError = '';
|
||||
let botSecrets: Array<{ id: string; name: string; description: string; used_by: string[] }> = [];
|
||||
let secretName = '';
|
||||
@@ -694,6 +695,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPublicCommands() {
|
||||
try {
|
||||
const response = await fetch(`${serverAddress}/api/v1/bot/commands`);
|
||||
if (response.ok) publicBotCommands = await response.json();
|
||||
} catch {
|
||||
publicBotCommands = [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadBotSecrets() {
|
||||
try {
|
||||
const response = await fetch(`${serverAddress}/api/v1/bot/secrets`, { headers: { authorization: `Bearer ${sessionToken}` } });
|
||||
@@ -940,6 +950,7 @@
|
||||
|
||||
onMount(() => {
|
||||
void checkServer();
|
||||
void loadPublicCommands();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1109,5 +1120,18 @@
|
||||
{#if overlayDiagnosticsOpen}<div class="diagnostics-details">{#each overlayVariableWarnings() as warning}<div>{warning}</div>{/each}</div>{/if}
|
||||
</section>
|
||||
{/if}
|
||||
{#if !authenticated && publicBotCommands.length}
|
||||
<section class="panel public-command-catalog">
|
||||
<div class="panel-header"><span>PUBLIC BOT COMMANDS</span></div>
|
||||
<div class="settings-body">
|
||||
<div class="micro">AVAILABLE COMMANDS</div>
|
||||
<div class="bot-command-list">
|
||||
{#each publicBotCommands as command}
|
||||
<article class="bot-command-row"><div><strong>!{command.name}</strong><span class="bot-command-description">{command.description}</span>{#if command.tags.length}<div class="micro">{command.tags.join(' · ')}</div>{/if}</div><div class="bot-command-meta"><span>{command.permission_level.toUpperCase()}</span></div></article>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user