From 261634e213fa328dfa9ae03200c992f3c28adb24 Mon Sep 17 00:00:00 2001 From: GRZ4NA Date: Sun, 20 Jun 2021 16:09:17 +0200 Subject: [PATCH] ProcessPhrase is now a static method of the "Command" class --- src/Commands.ts | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/Commands.ts b/src/Commands.ts index ac0562b..0f97702 100644 --- a/src/Commands.ts +++ b/src/Commands.ts @@ -39,8 +39,8 @@ class Command { constructor(options: CommandBuilder) { this.name = options.name.split(' ').join('_'); - this.aliases = ProcessPhrase(options.aliases); - this.keywords = ProcessPhrase(options.keywords); + this.aliases = Command.ProcessPhrase(options.aliases); + this.keywords = Command.ProcessPhrase(options.keywords); this.description = options.description || "No description"; this.usage = options.usage || ""; this.permissions = new Permissions(options.permissions || 0); @@ -56,6 +56,22 @@ class Command { throw new PermissionsError(this, message?.member); } } + static ProcessPhrase(phrase?: string | string[]) : string[] { + if(Array.isArray(phrase)) { + const buff = phrase.map((p) => { + return p.split(' ').join('_'); + }); + return buff; + } + else if(typeof phrase == 'string') { + const buff = []; + buff.push(phrase.split(' ').join('_')); + return buff; + } + else { + return []; + } + } } class CommandsManager { list: Command[]; @@ -103,23 +119,5 @@ class CommandsManager { } } -//FUNCTIONS -const ProcessPhrase = (phrase?: string | string[]) : string[] => { - if(Array.isArray(phrase)) { - const buff = phrase.map((p) => { - return p.split(' ').join('_'); - }); - return buff; - } - else if(typeof phrase == 'string') { - const buff = []; - buff.push(phrase.split(' ').join('_')); - return buff; - } - else { - return []; - } -} - //EXPORTS export { Command, CommandsManager } \ No newline at end of file