/[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 25 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    
15  class App {  class App {
16      constructor(rootdir) {      constructor(rootdir) {
# Line 26  class App { Line 28  class App {
28                  Intents.FLAGS.DIRECT_MESSAGE_TYPING,                  Intents.FLAGS.DIRECT_MESSAGE_TYPING,
29                  Intents.FLAGS.GUILD_PRESENCES,                  Intents.FLAGS.GUILD_PRESENCES,
30                  Intents.FLAGS.GUILD_MEMBERS,                  Intents.FLAGS.GUILD_MEMBERS,
31                    Intents.FLAGS.GUILD_BANS
32              ]              ]
33          });          });
34    
# Line 35  class App { Line 38  class App {
38          this.logger = new Logger();          this.logger = new Logger();
39          this.spamFilter = new SpamFilter();          this.spamFilter = new SpamFilter();
40          this.antiRaid = new AntiRaid();          this.antiRaid = new AntiRaid();
41            this.messageFilter = new MessageFilter();
42          this.boot();          this.boot();
43      }      }
44    
45      boot() {      boot() {
46          this.on('ready', () => {          this.on('ready', () => {
47              console.log("Logged in as " + this.client.user.tag);              console.log("Logged in as " + this.client.user.tag);
48    
49                this.client.user.setStatus(random(['dnd', 'idle']));
50                this.client.user.setActivity("over the server", { type: "WATCHING" });
51    
52              server();              server();
53          });          });
54    
55          this.on('messageCreate', async (message) => {          this.on('messageCreate', async (message) => {
56              if (message.author.bot) {              if (message.author.bot || !message.guild || message.channel.type == 'dm') {
57                  return;                  return;
58              }              }
59    
60              await (this.msg = message);              await (this.msg = message);
61                            
62             // await this.spamFilter.start(message);              await this.spamFilter.start(message);
63                await this.messageFilter.start(message, this.commandManager);
64    
65              await this.commandManager.setMessage(message);              await this.commandManager.setMessage(message);
66    
67              const valid = await this.commandManager.valid();              const valid = await this.commandManager.valid();
68              const has = await this.commandManager.has();              const has = await this.commandManager.has();
69              const snippet = await this.commandManager.snippet();              const snippet = await this.commandManager.snippet();
70                const allowed = await this.commandManager.verify();
71                            
72              if (valid && has) {              if (valid && has && allowed) {
73                  await this.exec();                  await this.exec();
74              }              }
75              else if (valid && snippet !== undefined) {              else if (valid && snippet !== undefined) {
# Line 70  class App { Line 80  class App {
80              else if (valid && !has) {              else if (valid && !has) {
81                  await this.commandManager.notFound();                  await this.commandManager.notFound();
82              }              }
83                else if (valid && has && !allowed) {
84                    await this.commandManager.notAllowed();
85                }
86          });          });
87    
88          this.on("messageUpdate", async (oldMessage, newMessage) => {          this.on("messageUpdate", async (oldMessage, newMessage) => {
89              if (oldMessage.author.bot)              if (oldMessage.author.bot || oldMessage.content === newMessage.content)
90                  return;                  return;
91    
92              await this.logger.logEdit(oldMessage, newMessage);              await this.logger.logEdit(oldMessage, newMessage);
93          });          });
94    
95    
96            this.on('guildBanAdd', async (ban) => {
97                console.log('test');
98                await this.logger.logBanned(ban);
99            });
100    
101            this.on('guildBanRemove', async (ban) => {
102                console.log('test');
103                await this.logger.logUnbanned(ban);
104            });
105    
106          this.on("messageDelete", async (message) => {          this.on("messageDelete", async (message) => {
107              if (message.author.bot)              if (message.author.bot)
108                  return;                  return;
# Line 106  class App { Line 130  class App {
130          this.on('guildMemberAdd', async (member) => {          this.on('guildMemberAdd', async (member) => {
131              console.log('Joined');              console.log('Joined');
132              await this.antiRaid.start(member);              await this.antiRaid.start(member);
133                await this.logger.logJoined(member);
134            });
135    
136            this.on('guildMemberRemove', async (member) => {
137                await this.logger.logLeft(member);
138          });          });
139      }      }
140    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26