Make displaynames with spaces work

This commit is contained in:
MTRNord
2023-09-03 15:44:47 +02:00
parent b67bae2cd1
commit 80e3578011
+10 -11
View File
@@ -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<MjolnirContext>(
"displayname",
findPresentationType("string"),
),
),
command: execSetDisplayNameCommand
})
// !draupnir displayname <displayname>
export async function execSetDisplayNameCommand(this: MjolnirContext, _keywords: ParsedKeywords, displayname: string): Promise<CommandResult<any>> {
export async function execSetDisplayNameCommand(this: MjolnirContext, _keywords: ParsedKeywords, displaynameParts: string[]): Promise<CommandResult<any>> {
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);
}