From b67bae2cd1d4f412d9950218c9b5a75b2ee31dba Mon Sep 17 00:00:00 2001 From: MTRNord Date: Sun, 3 Sep 2023 15:37:22 +0200 Subject: [PATCH] Add missing matrix interface adaptor and use CommandError --- src/commands/SetDisplayNameCommand.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/commands/SetDisplayNameCommand.ts b/src/commands/SetDisplayNameCommand.ts index 1148519f..6b9f1db9 100644 --- a/src/commands/SetDisplayNameCommand.ts +++ b/src/commands/SetDisplayNameCommand.ts @@ -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 : ''); - 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 +})