UNPKG

@pubby/sdk

Version:
45 lines (43 loc) 1.68 kB
var Command = /** @class */ (function () { function Command(options) { var _this = this; var _a, _b, _c; this.options = options; (_a = options.enabled) !== null && _a !== void 0 ? _a : (options.enabled = true); options.pipeline = [ function (msg, ctx) { var _a; var text = msg.text; text = text.trim().replace(/^.*\s/, ""); var _b = _this.commands.params.getCommand((_a = _this.options.usage) !== null && _a !== void 0 ? _a : "", text), command = _b.command, args = _b.args; Object.assign(ctx, { _: command, }, args); return true; }, ].concat((_b = options.pipeline) !== null && _b !== void 0 ? _b : [], (_c = options.handler) !== null && _c !== void 0 ? _c : this.__handler__.bind(this)); } Object.defineProperty(Command.prototype, "pubby", { get: function () { var _a; return (_a = this.commands) === null || _a === void 0 ? void 0 : _a.pubby; }, enumerable: false, configurable: true }); Object.defineProperty(Command.prototype, "aliases", { get: function () { return [].concat(this.options.command); }, enumerable: false, configurable: true }); Command.prototype.__handler__ = function (msg, ctx) { if (this[ctx._]) { return this[ctx._].call(this, msg, ctx); } }; Command.prototype.run = function (message, args) { }; return Command; }()); export { Command };