1 | "use strict";
|
2 | var __importStar = (this && this.__importStar) || function (mod) {
|
3 | if (mod && mod.__esModule) return mod;
|
4 | var result = {};
|
5 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
6 | result["default"] = mod;
|
7 | return result;
|
8 | };
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | const log = logger.withScope('handleCommand');
|
11 | const discord_js_1 = require("discord.js");
|
12 | const utils_1 = require("./utils");
|
13 | const commands = __importStar(require("./commands"));
|
14 | exports.default = ({ content, author, channel }) => {
|
15 | log.info('Command received!');
|
16 | content = content.trim();
|
17 | let command = content.split(' ')[0];
|
18 | const argv = content.replace(command, '')
|
19 | .split(' ')
|
20 | .map(str => str.trim())
|
21 | .filter(str => str);
|
22 | if (!command)
|
23 | command = 'help';
|
24 | if (!Object.keys(commands).includes(command))
|
25 | return channel.send(`Command \`${command}\` not found!`);
|
26 | if (command === 'eval') {
|
27 |
|
28 | argv.unshift(channel instanceof discord_js_1.TextChannel && !utils_1.hasAdmin(author, channel.guild)
|
29 | ? 'no'
|
30 | : 'yes');
|
31 | }
|
32 |
|
33 | commands[command].run(argv, channel);
|
34 | };
|