feat: Add slashcommand api
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user