6 |
const { escapeRegex } = require("./util"); |
const { escapeRegex } = require("./util"); |
7 |
|
|
8 |
class CommandManager { |
class CommandManager { |
9 |
constructor(cmdDir) { |
constructor(cmdDir, loadCommands = true, loadSnippets = true) { |
10 |
this.msg = null; |
this.msg = null; |
11 |
this.commandsDirectory = cmdDir; |
this.commandsDirectory = cmdDir; |
12 |
this.commands = []; |
this.commands = []; |
15 |
this.args = []; |
this.args = []; |
16 |
this.options = []; |
this.options = []; |
17 |
this.normalArgs = []; |
this.normalArgs = []; |
18 |
this.loadCommands(); |
|
19 |
this.snippetManager = new SnippetManager(); |
if (loadCommands) |
20 |
|
this.loadCommands(); |
21 |
|
|
22 |
|
if (loadSnippets) |
23 |
|
this.snippetManager = new SnippetManager(); |
24 |
|
|
25 |
this.shield = new Shield(); |
this.shield = new Shield(); |
26 |
} |
} |
27 |
|
|
29 |
this.msg = msg; |
this.msg = msg; |
30 |
this.argv = msg.content.split(/ +/g); |
this.argv = msg.content.split(/ +/g); |
31 |
this.args = this.argv; |
this.args = this.argv; |
32 |
this.commandName = this.args.shift().trim().replace(new RegExp(`^${escapeRegex(app.config.get('prefix'))}`), ""); |
this.commandName = this.args.shift().trim().replace(new RegExp(`^${escapeRegex(app.config.props[msg.guild.id].prefix)}`), ""); |
33 |
} |
} |
34 |
|
|
35 |
loadCommands() { |
loadCommands() { |
59 |
} |
} |
60 |
|
|
61 |
valid() { |
valid() { |
62 |
return this.msg.content.startsWith(app.config.get('prefix')); |
return this.msg.content.startsWith(app.config.props[this.msg.guild.id].prefix); |
63 |
} |
} |
64 |
|
|
65 |
async notFound() { |
async notFound() { |