From 80e35780117ab15eceb111745ae7dc2fee7d5dca Mon Sep 17 00:00:00 2001 From: MTRNord Date: Sun, 3 Sep 2023 15:44:47 +0200 Subject: [PATCH] Make displaynames with spaces work --- src/commands/SetDisplayNameCommand.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/commands/SetDisplayNameCommand.ts b/src/commands/SetDisplayNameCommand.ts index 6b9f1db9..3414c061 100644 --- a/src/commands/SetDisplayNameCommand.ts +++ b/src/commands/SetDisplayNameCommand.ts @@ -1,5 +1,5 @@ import { defineInterfaceCommand, findTableCommand } from "./interface-manager/InterfaceCommand"; -import { ParsedKeywords, findPresentationType, parameters } from "./interface-manager/ParameterParsing"; +import { ParsedKeywords, RestDescription, findPresentationType, parameters } from "./interface-manager/ParameterParsing"; import { MjolnirContext } from "./CommandHandler"; import { CommandError, CommandResult } from "./interface-manager/Validation"; import { tickCrossRenderer } from "./interface-manager/MatrixHelpRenderer"; @@ -10,19 +10,19 @@ defineInterfaceCommand({ table: "mjolnir", designator: ["displayname"], summary: "Sets the displayname of the draupnir instance to the specified value in all rooms.", - parameters: parameters([ - { - name: 'displayname', - acceptor: findPresentationType("string"), - description: 'The displayname to set.' - } - ]), + parameters: parameters( + [], + new RestDescription( + "displayname", + findPresentationType("string"), + ), + ), command: execSetDisplayNameCommand }) // !draupnir displayname -export async function execSetDisplayNameCommand(this: MjolnirContext, _keywords: ParsedKeywords, displayname: string): Promise> { - +export async function execSetDisplayNameCommand(this: MjolnirContext, _keywords: ParsedKeywords, displaynameParts: string[]): Promise> { + const displayname = displaynameParts.join(' '); try { await this.client.setDisplayName(displayname); } catch (e) { @@ -30,7 +30,6 @@ export async function execSetDisplayNameCommand(this: MjolnirContext, _keywords: return CommandError.Result(`Failed to set displayname to ${displayname}: ${message}`) } - return CommandResult.Ok(undefined); }