/[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 5 by rakin, Mon Jul 29 17:28:11 2024 UTC revision 27 by rakin, Mon Jul 29 17:28:16 2024 UTC
# Line 2  const fs = require("fs"); Line 2  const fs = require("fs");
2  const path = require("path");  const path = require("path");
3  const MessageEmbed = require("./MessageEmbed");  const MessageEmbed = require("./MessageEmbed");
4  const SnippetManager = require("./SnippetManager");  const SnippetManager = require("./SnippetManager");
5    const Shield = require("./Shield");
6  const { escapeRegex } = require("./util");  const { escapeRegex } = require("./util");
7    
8  class CommandManager {  class CommandManager {
# Line 12  class CommandManager { Line 13  class CommandManager {
13          this.commandName = "";          this.commandName = "";
14          this.argv = [];          this.argv = [];
15          this.args = [];          this.args = [];
16            this.options = [];
17            this.normalArgs = [];
18          this.loadCommands();          this.loadCommands();
19          this.snippetManager = new SnippetManager();          this.snippetManager = new SnippetManager();
20            this.shield = new Shield();
21      }      }
22    
23      setMessage(msg) {      setMessage(msg) {
# Line 42  class CommandManager { Line 46  class CommandManager {
46      }      }
47    
48      snippet() {      snippet() {
49          return this.snippetManager.find(this.commandName);          return this.snippetManager.find(this.msg.guild.id, this.commandName);
50      }      }
51    
52      hasValid() {      hasValid() {
# Line 65  class CommandManager { Line 69  class CommandManager {
69          }          }
70      }      }
71    
72        async notAllowed() {
73            if (app.config.get('warn_notallowed')) {
74                await app.msg.reply({
75                    embeds: [
76                        new MessageEmbed()
77                        .setColor('#f14a60')
78                        .setDescription(`:x: You don't have permission to run this command.`)
79                    ]
80                });
81            }
82        }
83    
84      async exec() {      async exec() {
85          return await this.commands[this.commandName].handle(this.msg, this);          let cmd = this.commands[this.commandName];
86    
87            if (cmd.needsOptionParse) {
88                this.normalArgs = await this.args.filter(arg => arg[0] !== '-');
89                this.options = await this.args.filter(arg => arg[0] === '-');
90            }
91    
92            return await cmd.handle(this.msg, this);
93        }
94    
95        verify() {
96            return this.shield.verify(this.msg, this);
97      }      }
98  }  }
99    

Legend:
Removed from v.5  
changed lines
  Added in v.27

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26