/[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 11 by rakin, Mon Jul 29 17:28:13 2024 UTC revision 27 by rakin, Mon Jul 29 17:28:16 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    const AFKEngine = require("./AFKEngine");
15    
16  class App {  class App {
17      constructor(rootdir) {      constructor(rootdir) {
# Line 26  class App { Line 29  class App {
29                  Intents.FLAGS.DIRECT_MESSAGE_TYPING,                  Intents.FLAGS.DIRECT_MESSAGE_TYPING,
30                  Intents.FLAGS.GUILD_PRESENCES,                  Intents.FLAGS.GUILD_PRESENCES,
31                  Intents.FLAGS.GUILD_MEMBERS,                  Intents.FLAGS.GUILD_MEMBERS,
32                    Intents.FLAGS.GUILD_BANS
33              ]              ]
34          });          });
35    
# Line 35  class App { Line 39  class App {
39          this.logger = new Logger();          this.logger = new Logger();
40          this.spamFilter = new SpamFilter();          this.spamFilter = new SpamFilter();
41          this.antiRaid = new AntiRaid();          this.antiRaid = new AntiRaid();
42            this.messageFilter = new MessageFilter();
43            this.afkEngine = new AFKEngine();
44          this.boot();          this.boot();
45      }      }
46    
47      boot() {      boot() {
48          this.on('ready', () => {          this.on('ready', () => {
49              console.log("Logged in as " + this.client.user.tag);              console.log("Logged in as " + this.client.user.tag);
50    
51                this.client.user.setStatus(random(['dnd', 'idle']));
52                this.client.user.setActivity("over the server", { type: "WATCHING" });
53    
54              server();              server();
55          });          });
56    
# Line 51  class App { Line 61  class App {
61    
62              await (this.msg = message);              await (this.msg = message);
63                            
64              //await this.spamFilter.start(message);              await this.spamFilter.start(message);
65                await this.messageFilter.start(message, this.commandManager);
66    
67              await this.commandManager.setMessage(message);              await this.commandManager.setMessage(message);
68    
# Line 65  class App { Line 76  class App {
76              }              }
77              else if (valid && snippet !== undefined) {              else if (valid && snippet !== undefined) {
78                  await message.channel.send({                  await message.channel.send({
79                      content: snippet.content                      content: snippet.content,
80                        files: snippet.files.map(f => {
81                            return {
82                                attachment: path.resolve(__dirname, '..', 'storage', f)
83                            }
84                        })
85                  });                  });
86              }              }
87              else if (valid && !has) {              else if (valid && !has) {
# Line 74  class App { Line 90  class App {
90              else if (valid && has && !allowed) {              else if (valid && has && !allowed) {
91                  await this.commandManager.notAllowed();                  await this.commandManager.notAllowed();
92              }              }
93                else if(!valid) {
94                    await this.afkEngine.start(message);
95                }
96          });          });
97    
98          this.on("messageUpdate", async (oldMessage, newMessage) => {          this.on("messageUpdate", async (oldMessage, newMessage) => {
99              if (oldMessage.author.bot)              if (oldMessage.author.bot || oldMessage.content === newMessage.content)
100                  return;                  return;
101    
102              await this.logger.logEdit(oldMessage, newMessage);              await this.logger.logEdit(oldMessage, newMessage);
103          });          });
104    
105    
106            this.on('guildBanAdd', async (ban) => {
107                console.log('test');
108                await this.logger.logBanned(ban);
109            });
110    
111            this.on('guildBanRemove', async (ban) => {
112                console.log('test');
113                await this.logger.logUnbanned(ban);
114            });
115    
116          this.on("messageDelete", async (message) => {          this.on("messageDelete", async (message) => {
117              if (message.author.bot)              if (message.author.bot)
118                  return;                  return;
# Line 110  class App { Line 140  class App {
140          this.on('guildMemberAdd', async (member) => {          this.on('guildMemberAdd', async (member) => {
141              console.log('Joined');              console.log('Joined');
142              await this.antiRaid.start(member);              await this.antiRaid.start(member);
143                await this.logger.logJoined(member);
144            });
145    
146            this.on('guildMemberRemove', async (member) => {
147                await this.logger.logLeft(member);
148          });          });
149      }      }
150    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26