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

Diff of /trunk/src/App.js

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

revision 10 by rakin, Mon Jul 29 17:28:12 2024 UTC revision 23 by rakin, Mon Jul 29 17:28:15 2024 UTC
# Line 9  const Logger = require("./Logger"); Line 9  const Logger = require("./Logger");
9  const SpamFilter = require("./SpamFilter");  const SpamFilter = require("./SpamFilter");
10  const server = require("./server");  const server = require("./server");
11  const AntiRaid = require("./AntiRaid");  const AntiRaid = require("./AntiRaid");
12    const MessageFilter = require("./MessageFilter");
13    const { random } = require("../commands/pixabay");
14    
15  class App {  class App {
16      constructor(rootdir) {      constructor(rootdir) {
# Line 35  class App { Line 37  class App {
37          this.logger = new Logger();          this.logger = new Logger();
38          this.spamFilter = new SpamFilter();          this.spamFilter = new SpamFilter();
39          this.antiRaid = new AntiRaid();          this.antiRaid = new AntiRaid();
40            this.messageFilter = new MessageFilter();
41          this.boot();          this.boot();
42      }      }
43    
44      boot() {      boot() {
45          this.on('ready', () => {          this.on('ready', () => {
46              console.log("Logged in as " + this.client.user.tag);              console.log("Logged in as " + this.client.user.tag);
47    
48                this.client.user.setStatus(random(['dnd', 'idle']));
49                this.client.user.setActivity("over the server", { type: "WATCHING" });
50    
51              server();              server();
52          });          });
53    
54          this.on('messageCreate', async (message) => {          this.on('messageCreate', async (message) => {
55              if (message.author.bot) {              if (message.author.bot || !message.guild || message.channel.type == 'dm') {
56                  return;                  return;
57              }              }
58    
59              await (this.msg = message);              await (this.msg = message);
60                            
61             // await this.spamFilter.start(message);              await this.spamFilter.start(message);
62                await this.messageFilter.start(message, this.commandManager);
63    
64              await this.commandManager.setMessage(message);              await this.commandManager.setMessage(message);
65    
66              const valid = await this.commandManager.valid();              const valid = await this.commandManager.valid();
67              const has = await this.commandManager.has();              const has = await this.commandManager.has();
68              const snippet = await this.commandManager.snippet();              const snippet = await this.commandManager.snippet();
69                const allowed = await this.commandManager.verify();
70                            
71              if (valid && has) {              if (valid && has && allowed) {
72                  await this.exec();                  await this.exec();
73              }              }
74              else if (valid && snippet !== undefined) {              else if (valid && snippet !== undefined) {
# Line 70  class App { Line 79  class App {
79              else if (valid && !has) {              else if (valid && !has) {
80                  await this.commandManager.notFound();                  await this.commandManager.notFound();
81              }              }
82                else if (valid && has && !allowed) {
83                    await this.commandManager.notAllowed();
84                }
85          });          });
86    
87          this.on("messageUpdate", async (oldMessage, newMessage) => {          this.on("messageUpdate", async (oldMessage, newMessage) => {

Legend:
Removed from v.10  
changed lines
  Added in v.23

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26