feat: Add slashcommand api

This commit is contained in:
2026-06-05 17:12:26 +02:00
parent 4070ef6caf
commit 8ecfc9a1fe
101 changed files with 3526 additions and 147 deletions

View File

@@ -39,6 +39,7 @@ import type {
PluginApiCustomStreamRequest,
PluginApiMessageAsPluginUserRequest,
PluginApiServerSettingsUpdate,
PluginApiSlashCommandContext,
PluginApiTypingEvent,
TojuClientPluginApi,
TojuPluginDisposable
@@ -77,6 +78,16 @@ export class PluginClientApiService {
const assertEvent = (eventName: string): void => this.assertDeclaredEvent(manifest, eventName);
return deepFreeze<TojuClientPluginApi>({
commands: {
list: () => {
requireCapability('ui.commands');
return this.uiRegistry.slashCommands();
},
register: (id, contribution) => {
requireCapability('ui.commands');
return this.uiRegistry.registerSlashCommand(pluginId, id, contribution);
}
},
channels: {
addAudioChannel: (request) => {
requireCapability('channels.manage');
@@ -513,6 +524,15 @@ export class PluginClientApiService {
};
}
createSlashCommandContext(request: { args: Record<string, string>; command: string; rawArgs: string }): PluginApiSlashCommandContext {
return {
...this.createActionContext('slashCommand'),
args: request.args,
command: request.command,
rawArgs: request.rawArgs
};
}
private assertDeclaredEvent(manifest: TojuPluginManifest, eventName: string): void {
const declared = manifest.events?.some((event) => event.eventName === eventName) ?? false;