Add missing matrix interface adaptor and use CommandError

This commit is contained in:
MTRNord
2023-09-03 15:37:22 +02:00
parent 4f4487c58e
commit b67bae2cd1
+10 -5
View File
@@ -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
})