/[sudobot]/trunk/src/CommandManager.js
ViewVC logotype

Diff of /trunk/src/CommandManager.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 45 by rakin, Mon Jul 29 17:28:16 2024 UTC revision 46 by rakin, Mon Jul 29 17:28:21 2024 UTC
# Line 6  const Shield = require("./Shield"); Line 6  const Shield = require("./Shield");
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 = [];
# Line 15  class CommandManager { Line 15  class CommandManager {
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    
# Line 24  class CommandManager { Line 29  class CommandManager {
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() {
# Line 54  class CommandManager { Line 59  class CommandManager {
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() {

Legend:
Removed from v.45  
changed lines
  Added in v.46

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26