Archived
removed keywords
This commit is contained in:
1 parent
b74dff1af9
commit
f9c586dd14
4 files changed
+13
-71
No files matched your search
@@ -20,7 +20,6 @@ export class Command {
|
||||
name: string;
|
||||
parameters: Parameter[];
|
||||
aliases?: string[];
|
||||
keywords?: string[];
|
||||
description: string;
|
||||
usage?: string;
|
||||
permissionCheck: PermissionCheckTypes;
|
||||
@@ -64,7 +63,6 @@ export class Command {
|
||||
this.parameters = options.parameters.map((ps) => new Parameter(ps));
|
||||
}
|
||||
this.aliases = Command.processPhrase(options.aliases);
|
||||
this.keywords = Command.processPhrase(options.keywords);
|
||||
this.description = options.description || "No description";
|
||||
this.usage = options.usage || this.generateUsageFromArguments();
|
||||
this.permissionCheck =
|
||||
|
||||
+12
-59
@@ -31,48 +31,18 @@ export class CommandManager {
|
||||
* @param {GetMode} [mode='ALL'] - specifies which types of command triggers will be used to find the command [*NO_PREFIX* - only keywords; *PREFIX* - names and aliases]
|
||||
* @returns *Command* | *null*
|
||||
*/
|
||||
get(phrase: string, mode?: GetMode): Command | null {
|
||||
if (!mode) mode = "ALL";
|
||||
get(phrase: string): Command | null {
|
||||
let command: Command | null = null;
|
||||
this.list.map((c) => {
|
||||
switch (mode) {
|
||||
case "PREFIX":
|
||||
if (c.name == phrase) {
|
||||
command = c;
|
||||
}
|
||||
c.aliases &&
|
||||
c.aliases.map((a) => {
|
||||
if (a == phrase) {
|
||||
command = c;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "NO_PREFIX":
|
||||
c.keywords &&
|
||||
c.keywords.map((k) => {
|
||||
if (k == phrase) {
|
||||
command = c;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "ALL":
|
||||
if (c.name == phrase) {
|
||||
command = c;
|
||||
}
|
||||
c.aliases &&
|
||||
c.aliases.map((a) => {
|
||||
if (a == phrase) {
|
||||
command = c;
|
||||
}
|
||||
});
|
||||
c.keywords &&
|
||||
c.keywords.map((k) => {
|
||||
if (k == phrase) {
|
||||
command = c;
|
||||
}
|
||||
});
|
||||
break;
|
||||
if (c.name == phrase) {
|
||||
command = c;
|
||||
}
|
||||
c.aliases &&
|
||||
c.aliases.map((a) => {
|
||||
if (a == phrase) {
|
||||
command = c;
|
||||
}
|
||||
});
|
||||
});
|
||||
return command;
|
||||
}
|
||||
@@ -105,17 +75,6 @@ export class CommandManager {
|
||||
ar.splice(i, 1);
|
||||
}
|
||||
});
|
||||
this.list.map((c) => {
|
||||
command.keywords &&
|
||||
command.keywords.map((k, i, a) => {
|
||||
if (c.keywords && c.keywords.indexOf(k) != -1) {
|
||||
console.warn(
|
||||
`[⚠ WARN] The name "${k}" is already a registered KEYWORD for the "${c.name}" command. It will be removed from the "${command.name}" command`
|
||||
);
|
||||
a.splice(i, 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
this.list.push(command);
|
||||
return true;
|
||||
} catch (e) {
|
||||
@@ -130,16 +89,10 @@ export class CommandManager {
|
||||
* @returns *CommandMessagesStructure* | *null*
|
||||
*/
|
||||
fetchFromMessage(message: Message): CommandMessageStructure | null {
|
||||
if (!message.author.bot) {
|
||||
let prefix = false;
|
||||
if (message.content.startsWith(this.prefix)) {
|
||||
prefix = true;
|
||||
}
|
||||
const content = prefix
|
||||
? message.content.replace(this.prefix, "")
|
||||
: message.content;
|
||||
if (!message.author.bot && message.content.startsWith(this.prefix)) {
|
||||
const content = message.content.replace(this.prefix, "");
|
||||
const name = content.split(" ")[0];
|
||||
const command = this.get(name, prefix ? "PREFIX" : "NO_PREFIX");
|
||||
const command = this.get(name);
|
||||
if (command) {
|
||||
const argumentsText = content.replace(name, "");
|
||||
const paramsList = argumentsText
|
||||
|
||||
+1
-9
@@ -31,8 +31,7 @@ export class HelpMessage extends Command {
|
||||
if (helpMsg != null) {
|
||||
if (param("command_name")) {
|
||||
const cmd: Command | null = cmdManager.get(
|
||||
param("command_name")?.toString() || "",
|
||||
"ALL"
|
||||
param("command_name")?.toString() || ""
|
||||
);
|
||||
if (cmd) {
|
||||
helpMsg.setTitle(
|
||||
@@ -66,13 +65,6 @@ export class HelpMessage extends Command {
|
||||
});
|
||||
helpMsg.addField("Aliases:", aList, false);
|
||||
}
|
||||
if (cmd.keywords && cmd.keywords.length > 0) {
|
||||
let kwrdList: string = "";
|
||||
cmd.keywords.map((k) => {
|
||||
kwrdList += k + "\n";
|
||||
});
|
||||
helpMsg.addField("Keywords:", kwrdList, false);
|
||||
}
|
||||
} else {
|
||||
throw new ReferenceError(
|
||||
`Command "${param(
|
||||
|
||||
@@ -22,7 +22,6 @@ export interface CommandBuilder {
|
||||
name: string;
|
||||
parameters?: ParameterSchema[] | "simple" | "no_input";
|
||||
aliases?: string[] | string;
|
||||
keywords?: string[] | string;
|
||||
description?: string;
|
||||
usage?: string;
|
||||
permissionCheck?: PermissionCheckTypes;
|
||||
|
||||
Reference in new issue
Block a user