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 |
|
|
14 |
class App { |
class App { |
15 |
constructor(rootdir) { |
constructor(rootdir) { |
36 |
this.logger = new Logger(); |
this.logger = new Logger(); |
37 |
this.spamFilter = new SpamFilter(); |
this.spamFilter = new SpamFilter(); |
38 |
this.antiRaid = new AntiRaid(); |
this.antiRaid = new AntiRaid(); |
39 |
|
this.messageFilter = new MessageFilter(); |
40 |
this.boot(); |
this.boot(); |
41 |
} |
} |
42 |
|
|
47 |
}); |
}); |
48 |
|
|
49 |
this.on('messageCreate', async (message) => { |
this.on('messageCreate', async (message) => { |
50 |
if (message.author.bot) { |
if (message.author.bot || !message.guild || message.channel.type == 'dm') { |
51 |
return; |
return; |
52 |
} |
} |
53 |
|
|
54 |
await (this.msg = message); |
await (this.msg = message); |
55 |
|
|
56 |
// await this.spamFilter.start(message); |
await this.spamFilter.start(message); |
57 |
|
await this.messageFilter.start(message, this.commandManager); |
58 |
|
|
59 |
await this.commandManager.setMessage(message); |
await this.commandManager.setMessage(message); |
60 |
|
|
61 |
const valid = await this.commandManager.valid(); |
const valid = await this.commandManager.valid(); |
62 |
const has = await this.commandManager.has(); |
const has = await this.commandManager.has(); |
63 |
const snippet = await this.commandManager.snippet(); |
const snippet = await this.commandManager.snippet(); |
64 |
|
const allowed = await this.commandManager.verify(); |
65 |
|
|
66 |
if (valid && has) { |
if (valid && has && allowed) { |
67 |
await this.exec(); |
await this.exec(); |
68 |
} |
} |
69 |
else if (valid && snippet !== undefined) { |
else if (valid && snippet !== undefined) { |
74 |
else if (valid && !has) { |
else if (valid && !has) { |
75 |
await this.commandManager.notFound(); |
await this.commandManager.notFound(); |
76 |
} |
} |
77 |
|
else if (valid && has && !allowed) { |
78 |
|
await this.commandManager.notAllowed(); |
79 |
|
} |
80 |
}); |
}); |
81 |
|
|
82 |
this.on("messageUpdate", async (oldMessage, newMessage) => { |
this.on("messageUpdate", async (oldMessage, newMessage) => { |