mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-06-04 06:41:18 +00:00
Add missing matrix interface adaptor and use CommandError
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { LogLevel, LogService } from "matrix-bot-sdk";
|
||||
import { defineInterfaceCommand } from "./interface-manager/InterfaceCommand";
|
||||
import { defineInterfaceCommand, findTableCommand } from "./interface-manager/InterfaceCommand";
|
||||
import { ParsedKeywords, findPresentationType, parameters } from "./interface-manager/ParameterParsing";
|
||||
import { MjolnirContext } from "./CommandHandler";
|
||||
import { CommandResult } from "./interface-manager/Validation";
|
||||
import { CommandError, CommandResult } from "./interface-manager/Validation";
|
||||
import { tickCrossRenderer } from "./interface-manager/MatrixHelpRenderer";
|
||||
import { defineMatrixInterfaceAdaptor } from "./interface-manager/MatrixInterfaceAdaptor";
|
||||
|
||||
|
||||
defineInterfaceCommand({
|
||||
@@ -26,10 +27,14 @@ export async function execSetDisplayNameCommand(this: MjolnirContext, _keywords:
|
||||
await this.client.setDisplayName(displayname);
|
||||
} catch (e) {
|
||||
const message = e.message || (e.body ? e.body.error : '<no message>');
|
||||
LogService.error("SetDisplayNameCommand", e);
|
||||
await this.mjolnir.managementRoomOutput.logMessage(LogLevel.ERROR, "SetDisplayNameCommand", `Failed to set displayname to ${displayname}: ${message}`);
|
||||
return CommandError.Result(`Failed to set displayname to ${displayname}: ${message}`)
|
||||
}
|
||||
|
||||
|
||||
return CommandResult.Ok(undefined);
|
||||
}
|
||||
|
||||
defineMatrixInterfaceAdaptor({
|
||||
interfaceCommand: findTableCommand("mjolnir", "displayname"),
|
||||
renderer: tickCrossRenderer
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user