mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
iterate PR based on feedback. Remove newballsplease cmd alias
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
6e61761012
commit
80479195c8
1 changed files with 19 additions and 26 deletions
|
@ -71,6 +71,16 @@ export const CommandCategories = {
|
||||||
|
|
||||||
type RunFn = ((roomId: string, args: string, cmd: string) => {error: any} | {promise: Promise<any>});
|
type RunFn = ((roomId: string, args: string, cmd: string) => {error: any} | {promise: Promise<any>});
|
||||||
|
|
||||||
|
interface ICommandOpts {
|
||||||
|
command: string;
|
||||||
|
aliases?: string[];
|
||||||
|
args?: string;
|
||||||
|
description: string;
|
||||||
|
runFn?: RunFn;
|
||||||
|
category: string;
|
||||||
|
hideCompletionAfterSpace?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
class Command {
|
class Command {
|
||||||
command: string;
|
command: string;
|
||||||
aliases: string[];
|
aliases: string[];
|
||||||
|
@ -80,30 +90,14 @@ class Command {
|
||||||
category: string;
|
category: string;
|
||||||
hideCompletionAfterSpace: boolean;
|
hideCompletionAfterSpace: boolean;
|
||||||
|
|
||||||
constructor({
|
constructor(opts: ICommandOpts) {
|
||||||
command,
|
this.command = opts.command;
|
||||||
aliases = [],
|
this.aliases = opts.aliases || [];
|
||||||
args = '',
|
this.args = opts.args || "";
|
||||||
description,
|
this.description = opts.description;
|
||||||
runFn = undefined,
|
this.runFn = opts.runFn;
|
||||||
category = CommandCategories.other,
|
this.category = opts.category || CommandCategories.other;
|
||||||
hideCompletionAfterSpace = false,
|
this.hideCompletionAfterSpace = opts.hideCompletionAfterSpace || false;
|
||||||
}: {
|
|
||||||
command: string;
|
|
||||||
aliases?: string[];
|
|
||||||
args?: string;
|
|
||||||
description: string;
|
|
||||||
runFn?: RunFn;
|
|
||||||
category: string;
|
|
||||||
hideCompletionAfterSpace?: boolean;
|
|
||||||
}) {
|
|
||||||
this.command = command;
|
|
||||||
this.aliases = aliases;
|
|
||||||
this.args = args;
|
|
||||||
this.description = description;
|
|
||||||
this.runFn = runFn;
|
|
||||||
this.category = category;
|
|
||||||
this.hideCompletionAfterSpace = hideCompletionAfterSpace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommand() {
|
getCommand() {
|
||||||
|
@ -853,7 +847,6 @@ export const Commands = [
|
||||||
}),
|
}),
|
||||||
new Command({
|
new Command({
|
||||||
command: 'discardsession',
|
command: 'discardsession',
|
||||||
aliases: ['newballsplease'],
|
|
||||||
description: _td('Forces the current outbound group session in an encrypted room to be discarded'),
|
description: _td('Forces the current outbound group session in an encrypted room to be discarded'),
|
||||||
runFn: function(roomId) {
|
runFn: function(roomId) {
|
||||||
try {
|
try {
|
||||||
|
@ -900,7 +893,7 @@ export const Commands = [
|
||||||
command: "whois",
|
command: "whois",
|
||||||
description: _td("Displays information about a user"),
|
description: _td("Displays information about a user"),
|
||||||
args: "<user-id>",
|
args: "<user-id>",
|
||||||
runFn: function (roomId, userId) {
|
runFn: function(roomId, userId) {
|
||||||
if (!userId || !userId.startsWith("@") || !userId.includes(":")) {
|
if (!userId || !userId.startsWith("@") || !userId.includes(":")) {
|
||||||
return reject(this.getUsage());
|
return reject(this.getUsage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue