-
Notifications
You must be signed in to change notification settings - Fork 24
/
command.js
1875 lines (1709 loc) · 54.3 KB
/
command.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
registerPlugin({
name: "Command Library",
description: "Library to handle and manage commands",
version: "1.4.4",
author: "Multivitamin <[email protected]>",
autorun: true,
backends: ["ts3", "discord"],
vars: [{
name: "NOT_FOUND_MESSAGE",
title: "Send a message if no command has been found?",
type: "select",
options: ["YES", "NO"],
default: "1"
}, {
name: "DEBUGLEVEL",
title: "Debug Messages (default is INFO)",
type: "select",
options: ["ERROR", "WARNING", "INFO", "VERBOSE"],
default: "2"
}]
}, (_, { DEBUGLEVEL, NOT_FOUND_MESSAGE }, { version }) => {
const engine = require("engine")
const event = require("event")
const backend = require("backend")
const format = require("format")
/**
* @param {number} level
* @return {(mode: number) => (...args: any[]) => void}
* @private
*/
function DEBUG(level) {
/**
* @param {number} mode the loglevel to log
* @param {number[]} args data to log
* @private
*/
const logger = (mode, ...args) => {
if (mode > level) return
engine.log(...args)
}
return mode => logger.bind(null, mode)
}
DEBUG.VERBOSE = 3
DEBUG.INFO = 2
DEBUG.WARNING = 1
DEBUG.ERROR = 0
/** @private */
const debug = DEBUG(parseInt(DEBUGLEVEL, 10))
////////////////////////////////////////////////////////////
//// TYPES ////
////////////////////////////////////////////////////////////
/**
* callback for the command event
* @callback createArgumentHandler
* @param {ArgType} arg
* @returns {Argument}
*/
/**
* @typedef ArgType
* @type {object}
* @property {StringArgument} string
* @property {NumberArgument} number
* @property {ClientArgument} client
* @property {RestArgument} rest
* @property {GroupArgument} or
* @property {GroupArgument} and
*/
// eslint-disable-next-line no-unused-vars
const ArgType = {}
/**
* @ignore
* @typedef CommanderTextMessage
* @type {object}
* @property {(msg: string) => void} reply function to reply back
* @property {Client} client the client which invoked the command
* @property {Record<string, any>} arguments arguments from the command
* @property {Message} raw raw message
* @property {DiscordMessage} [message]
*/
/**
* @ignore
* @typedef MessageEvent
* @type {object}
* @property {Client} client
* @property {Channel} channel
* @property {string} text
* @property {number} mode
* @property {DiscordMessage} [message]
*/
/**
* callback for the command event
* @callback execHandler
* @param {Client} invoker
* @param {Record<string, any>} args
* @param {(msg: string) => void} reply
* @param {MessageEvent} event
*/
/**
* callback for the command event
* @callback permissionHandler
* @param {Client} invoker
*/
/**
* @ignore
* @typedef ThrottleInterface
* @property {number} points
* @property {number} next
* @property {number} timeout
*/
////////////////////////////////////////////////////////////
//// EXCEPTIONS ////
////////////////////////////////////////////////////////////
/**
* class representing a ThrottleError
* @private
*/
class ThrottleError extends Error {
/** @param {string} err */
constructor(err) {
super(err)
}
}
/**
* class representing a TooManyArguments
* @private
*/
class TooManyArgumentsError extends Error {
/**
* @param {string} err
* @param {ParseError|undefined} parseError
*/
constructor(err, parseError) {
super(err)
this.parseError = parseError
}
}
/**
* class representing a ParseError
* gets thrown when an Argument has not been parsed successful
* @private
*/
class ParseError extends Error {
/**
* @param {string} err
* @param {Argument} argument
*/
constructor(err, argument) {
super(err)
this.argument = argument
}
}
/**
* class representing a SubCommandNotFoundError
* @private
*/
class CommandNotFoundError extends Error {
/** @param {string} err */
constructor(err) {
super(err)
}
}
/**
* class representing a PermissionError
* @private
*/
class PermissionError extends Error {
/** @param {string} err */
constructor(err) {
super(err)
}
}
////////////////////////////////////////////////////////////
//// ARGUMENTS ////
////////////////////////////////////////////////////////////
/**
* @name Argument
*/
class Argument {
constructor() {
/**
* @type {boolean}
* @private
*/
this._optional = false
/**
* @type {string}
* @private
*/
this._name = "_"
/**
* @type {string}
* @private
*/
this._display = "_"
/**
* @type {boolean}
* @private
*/
this._displayDefault = true
/**
* @type {any}
* @private
*/
this._default = undefined
}
/**
* @abstract
* @param {string} args
* @returns {any[]}
*/
validate(args) {
throw new Error("not implemented")
}
/**
* Sets an Argument as optional
* if the argument has not been parsed successful it will use the first argument which has been given inside this method
* @param {any} [fallback] the default value which should be set if this parameter has not been found
* @param {boolean} [displayDefault] wether it should display the default value when called with the #getUsage method
*/
optional(fallback, displayDefault = true) {
this._displayDefault = displayDefault
this._default = fallback
this._optional = true
return this
}
/** retrieves the default value if it had been set */
getDefault() {
return this._default
}
/** checks if the Argument has a default value */
hasDefault() {
return this._default !== undefined
}
/** gets the manual of a command */
getManual() {
if (this.isOptional()) {
if (this._displayDefault && this.hasDefault()) {
return `[${this._display}=${this.getDefault()}]`
} else {
return `[${this._display}]`
}
} else {
return `<${this._display}>`
}
}
/** checks if the Argument is optional */
isOptional() {
return this._optional
}
/**
* Sets a name for the argument to identify it later when the command gets dispatched
* This name will be used when passing the parsed argument to the exec function
* @param {string} name sets the name of the argument
* @param {string} [display] sets a beautified display name which will be used when the getManual command gets executed, if none given it will use the first parameter as display value
*/
setName(name, display) {
this._display = display === undefined ? name : display
if (typeof name !== "string") throw new Error("Argument of setName needs to be a string")
if (name.length < 1) throw new Error("Argument of setName needs to be at least 1 char long")
if (!name.match(/^[a-z0-9_]+$/i)) throw new Error("Argument of setName should contain only chars A-z, 0-9 and _")
this._name = name
return this
}
/**
* Retrieves the name of the Argument
* @returns {string} retrieves the arguments name
*/
getName() {
return this._name
}
/**
* creates new object with argument options
* @returns {ArgType}
*/
static createArgumentLayer() {
return {
string: new StringArgument(),
number: new NumberArgument(),
client: new ClientArgument(),
rest: new RestArgument(),
or: new GroupArgument("or"),
and: new GroupArgument("and")
}
}
}
/**
* @name StringArgument
*/
class StringArgument extends Argument {
constructor() {
super()
/**
* @type {?RegExp}
* @private
*/
this._regex = null
/**
* @type {?number}
* @private
*/
this._maxlen = null
/**
* @type {?number}
* @private
*/
this._minlen = null
/**
* @type {?string[]}
* @private
*/
this._whitelist = null
/**
* @type {boolean}
* @private
*/
this._uppercase = false
/**
* @type {boolean}
* @private
*/
this._lowercase = false
}
/**
* Validates the given String to the StringArgument
* @param {string} args the remaining args
*/
validate(args) {
const argArray = args.split(" ")
const str = argArray.shift()
return this._validate(str||"", argArray.join(" "))
}
/**
* Validates the given string to the StringArgument params
* @protected
* @param {string} arg string argument that should be parsed
* @param {string[]} rest the remaining args
*/
_validate(arg, ...rest) {
if (this._uppercase) arg = arg.toUpperCase()
if (this._lowercase) arg = arg.toLowerCase()
if (this._minlen !== null && this._minlen > arg.length) throw new ParseError(`String length not greater or equal! Expected at least ${this._minlen}, but got ${arg.length}`, this)
if (this._maxlen !== null && this._maxlen < arg.length) throw new ParseError(`String length not less or equal! Maximum ${this._maxlen} chars allowed, but got ${arg.length}`, this)
if (this._whitelist !== null && !this._whitelist.includes(arg)) throw new ParseError(`Invalid Input for ${arg}. Allowed words: ${this._whitelist.join(", ")}`, this)
if (this._regex !== null && !this._regex.test(arg)) throw new ParseError(`Regex missmatch, the input '${arg}' did not match the expression ${this._regex.toString()}`, this)
return [arg, ...rest]
}
/**
* Matches a regular expression pattern
* @param {RegExp} regex the regex which should be validated
*/
match(regex) {
this._regex = regex
return this
}
/**
* Sets the maximum Length of the String
* @param {number} len the maximum length of the argument
*/
max(len) {
this._maxlen = len
return this
}
/**
* Sets the minimum Length of the String
* @param {number} len the minimum length of the argument
*/
min(len) {
this._minlen = len
return this
}
/** converts the input to an upper case string */
forceUpperCase() {
this._lowercase = false
this._uppercase = true
return this
}
/** converts the input to a lower case string */
forceLowerCase() {
this._lowercase = true
this._uppercase = false
return this
}
/**
* creates a list of available whitelisted words
* @param {string[]} words array of whitelisted words
*/
whitelist(words) {
if (!Array.isArray(this._whitelist)) this._whitelist = []
this._whitelist.push(...words)
return this
}
}
/**
* @name RestArgument
*/
class RestArgument extends StringArgument {
/**
* Validates the given String to the RestArgument
* @param {string} args the remaining args
*/
validate(args) {
return super._validate(args, "")
}
}
/**
* @name NumberArgument
*/
class NumberArgument extends Argument {
constructor() {
super()
/**
* @type {?number}
* @private
*/
this._min = null
/**
* @type {?number}
* @private
*/
this._max = null
/**
* @type {boolean}
* @private
*/
this._int = false
/**
* @type {boolean}
* @private
*/
this._forcePositive = false
/**
* @type {boolean}
* @private
*/
this._forceNegative = false
}
/**
* Validates the given Number to the Object
* @param {string} args the remaining args
*/
validate(args) {
const argArray = args.split(" ")
const arg = argArray.shift()|| ""
const num = parseFloat(arg)
if (!(/^-?\d+(\.\d+)?$/).test(arg) || isNaN(num)) throw new ParseError(`"${arg}" is not a valid number`, this)
if (this._min !== null && this._min > num) throw new ParseError(`Number not greater or equal! Expected at least ${this._min}, but got ${num}`, this)
if (this._max !== null && this._max < num) throw new ParseError(`Number not less or equal! Expected at least ${this._max}, but got ${num}`, this)
if (this._int && num % 1 !== 0) throw new ParseError(`Given Number is not an Integer! (${num})`, this)
if (this._forcePositive && num <= 0) throw new ParseError(`Given Number is not Positive! (${num})`, this)
if (this._forceNegative && num >= 0) throw new ParseError(`Given Number is not Negative! (${num})`, this)
return [num, argArray.join(" ")]
}
/**
* specifies the minimum value
* @param {number} min the minimum length of the argument
*/
min(min) {
this._min = min
return this
}
/**
* specifies the maximum value
* @param {number} max the maximum length of the argument
*/
max(max) {
this._max = max
return this
}
/** specifies that the Number must be an integer (no floating point) */
integer() {
this._int = true
return this
}
/** specifies that the Number must be a positive Number */
positive() {
this._forcePositive = true
this._forceNegative = false
return this
}
/** specifies that the Number must be a negative Number */
negative() {
this._forcePositive = false
this._forceNegative = true
return this
}
}
/**
* Class representing a ClientArgument
* this Argument is capable to parse a Client UID or a simple UID
* inside the exec function it will resolve the found uid
* @name ClientArgument
*/
class ClientArgument extends Argument {
/**
* Validates and tries to parse the Client from the given input string
* @param {string} args the input from where the client gets extracted
*/
validate(args) {
switch (engine.getBackend()) {
case "ts3": return this._validateTS3(args)
case "discord": return this._validateDiscord(args)
default: throw new Error(`Unknown Backend ${engine.getBackend()}`)
}
}
/**
* Tries to validate a TeamSpeak Client URL or UID
* @param {string} args the input from where the client gets extracted
* @private
*/
_validateTS3(args) {
const match = args.match(/^(\[URL=client:\/\/\d*\/(?<url_uid>[/+a-z0-9]{27}=)~.*\].*\[\/URL\]|(?<uid>[/+a-z0-9]{27}=)) *(?<rest>.*)$/i)
if (!match || !match.groups) throw new ParseError("Client not found!", this)
return [match.groups.url_uid || match.groups.uid, match.groups.rest]
}
/**
* Tries to validate a Discord Client Name or ID
* @param {string} args the input from where the client gets extracted
* @private
*/
_validateDiscord(args) {
const match = args.match(/^(<@(?<id>\d{18})>|@(?<name>.*?)#\d{4}) *(?<rest>.*)$/i)
if (!match || !match.groups) throw new ParseError("Client not found!", this)
const { id, name, rest } = match.groups
if (id) {
return [id, rest]
} else if (name) {
const client = backend.getClientByName(name)
if (!client) throw new ParseError("Client not found!", this)
return [client.uid().split("/")[1], rest]
} else {
throw new ParseError("Client not found!", this)
}
}
}
/**
* @name GroupArgument
*/
class GroupArgument extends Argument {
/**
* @param {"or"|"and"} type
*/
constructor(type) {
super()
/**
* @type {"or"|"and"}
* @private
*/
this._type = type
/**
* @type {Argument[]}
* @private
*/
this._arguments = []
}
/**
* Validates the given String to the GroupArgument
* @param {string} args the remaining args
*/
validate(args) {
switch (this._type) {
case "or": return this._validateOr(args)
case "and": return this._validateAnd(args)
default: throw new Error(`got invalid group type '${this._type}'`)
}
}
/**
* Validates the given string to the "or" of the GroupArgument
* @param {string} args the remaining args
* @private
*/
_validateOr(args) {
/**
* @type {Error[]}
* @private
*/
const errors = []
/**
* @type {Record<string, any>}
* @private
*/
const resolved = {}
const valid = this._arguments.some(arg => {
try {
const result = arg.validate(args)
resolved[arg.getName()] = result[0]
return (args = result[1].trim(), true)
} catch (e) {
errors.push(e)
return false
}
})
if (!valid) throw new ParseError(`No valid match found`, this)
return [resolved, args]
}
/**
* Validates the given string to the "and" of the GroupArgument
* @param {string} args the remaining args
* @private
*/
_validateAnd(args) {
/**
* @type {Record<string, any>}
* @private
*/
const resolved = {}
/**
* @type {?Error}
* @private
*/
let error = null
this._arguments.some(arg => {
try {
const result = arg.validate(args)
resolved[arg.getName()] = result[0]
return (args = result[1].trim(), false)
} catch (e) {
error = e
return true
}
})
if (error !== null) throw error
return [resolved, args]
}
/**
* adds an argument to the command
* @param {createArgumentHandler|Argument} arg an argument to add
*/
addArgument(arg) {
if (typeof arg === "function") arg = arg(Argument.createArgumentLayer())
if (!(arg instanceof Argument)) throw new Error(`Typeof arg should be function or instance of Argument but got ${arg}`)
this._arguments.push(arg)
return this
}
}
////////////////////////////////////////////////////////////
//// Throttle ////
////////////////////////////////////////////////////////////
/**
* @name Throttle
*/
class Throttle {
constructor() {
/**
* @type {Record<string, ThrottleInterface>}
* @private
*/
this._throttled = {}
/**
* @type {number}
* @private
*/
this._penalty = 1
/**
* @type {number}
* @private
*/
this._initial = 1
/**
* @type {number}
* @private
*/
this._restore = 1
/**
* @type {number}
* @private
*/
this._tickrate = 1000
}
/* clears all timers */
stop() {
Object.values(this._throttled).forEach(({ timeout }) => clearTimeout(timeout))
return this
}
/**
* Defines how fast points will get restored
* @param {number} duration time in ms how fast points should get restored
*/
tickRate(duration) {
this._tickrate = duration
return this
}
/**
* The amount of points a command request costs
* @param {number} amount the amount of points that should be reduduced
*/
penaltyPerCommand(amount) {
this._penalty = amount
return this
}
/**
* The Amount of Points that should get restored per tick
* @param {number} amount the amount that should get restored
*/
restorePerTick(amount) {
this._restore = amount
return this
}
/**
* Sets the initial Points a user has at beginning
* @param {number} initial the Initial amount of Points a user has
*/
initialPoints(initial) {
this._initial = initial
return this
}
/**
* Reduces the given points for a Command for the given Client
* @param {Client} client the client which points should be removed
*/
throttle(client) {
this._reducePoints(client.uid())
return this.isThrottled(client)
}
/**
* Restores points from the given id
* @param {string} id the identifier for which the points should be stored
* @private
*/
_restorePoints(id) {
const throttle = this._throttled[id]
if (throttle === undefined) return
throttle.points += this._restore
if (throttle.points >= this._initial) {
Reflect.deleteProperty(this._throttled, id)
} else {
this._refreshTimeout(id)
}
}
/**
* Resets the timeout counter for a stored id
* @param {string} id the identifier which should be added
* @private
*/
_refreshTimeout(id) {
if (this._throttled[id] === undefined) return
clearTimeout(this._throttled[id].timeout)
// @ts-ignore
this._throttled[id].timeout = setTimeout(this._restorePoints.bind(this, id), this._tickrate)
this._throttled[id].next = Date.now() + this._tickrate
}
/**
* Removes points from an id
* @param {string} id the identifier which should be added
* @private
*/
_reducePoints(id) {
const throttle = this._createIdIfNotExists(id)
throttle.points -= this._penalty
this._refreshTimeout(id)
}
/**
* creates the identifier in the throttled object
* @param {string} id the identifier which should be added
* @private
*/
_createIdIfNotExists(id) {
if (Object.keys(this._throttled).includes(id)) return this._throttled[id]
this._throttled[id] = { points: this._initial, next: 0, timeout: 0 }
return this._throttled[id]
}
/**
* Checks if the given Client is affected by throttle limitations
* @param {Client} client the TeamSpeak Client which should get checked
*/
isThrottled(client) {
const throttle = this._throttled[client.uid()]
if (throttle === undefined) return false
return throttle.points <= 0
}
/**
* retrieves the time in milliseconds until a client can send his next command
* @param {Client} client the client which should be checked
* @returns returns the time a client is throttled in ms
*/
timeTillNextCommand(client) {
if (this._throttled[client.uid()] === undefined) return 0
return this._throttled[client.uid()].next - Date.now()
}
}
////////////////////////////////////////////////////////////
//// COMMAND ////
////////////////////////////////////////////////////////////
/**
* @name BaseCommand
*/
class BaseCommand {
/**
* @param {string} cmd
* @param {Collector} collector
*/
constructor(cmd, collector) {
/**
* @type {Collector}
* @protected
*/
this._collector = collector
/**
* @type {permissionHandler[]}
* @private
*/
this._permissionHandler = []
/**
* @type {execHandler[]}
* @protected
*/
this._execHandler = []
/**
* @type {string}
* @private
*/
this._prefix = ""
/**
* @type {string}
* @private
*/
this._help = ""
/**
* @type {string[]}
* @private
*/
this._manual = []
/**
* @type {string}
* @private
*/
this._name = cmd
/**
* @type {boolean}
* @private
*/
this._enabled = true
/**
* @type {?Throttle}
* @private
*/
this._throttle = null
/**
* @type {string[]}
* @private
*/
this._alias = []
}
/**
* @abstract
* @returns {string}
*/
getUsage() {
throw new Error("not implemented")
}
/**
* @abstract
* @param {Client} client
* @returns {Promise<boolean>}
*/
hasPermission(client) {
throw new Error("not implemented")
}
/**
* @abstract
* @param {string} args
* @returns {Record<string, any>}
*/
validate(args) {
throw new Error("not implemented")
}
/**
* @abstract
* @param {string} args
* @param {MessageEvent} ev
*/
dispatch(args, ev) {
throw new Error("not implemented")
}
/**
* one or more alias for this command
* @param {...string} alias
*/
alias(...alias) {
alias = alias.map(a => a.toLowerCase())
alias.forEach(a => Collector.isValidCommandName(a))
this._alias.push(...alias.filter(a => this._collector.getAvailableCommands(a)))
return this
}
/** checks if the command is enabled */
isEnabled() {
return this._enabled
}
/**
* enables the current command
*/
enable() {
this._enabled = true
return this
}
/**
* disables the current command
*/
disable() {
this._enabled = false
return this
}
/** gets the command name without its prefix */
getCommandName() {
return this._name
}
/** retrieves all registered alias names without prefix */