11 |
const AntiRaid = require("./AntiRaid"); |
const AntiRaid = require("./AntiRaid"); |
12 |
const MessageFilter = require("./MessageFilter"); |
const MessageFilter = require("./MessageFilter"); |
13 |
const { random } = require("../commands/pixabay"); |
const { random } = require("../commands/pixabay"); |
14 |
|
const AFKEngine = require("./AFKEngine"); |
15 |
|
const Starboard = require("./Starboard"); |
16 |
|
const { runTimeouts, setTimeoutv2 } = require("./setTimeout"); |
17 |
|
|
18 |
class App { |
class App { |
19 |
constructor(rootdir) { |
constructor(rootdir) { |
31 |
Intents.FLAGS.DIRECT_MESSAGE_TYPING, |
Intents.FLAGS.DIRECT_MESSAGE_TYPING, |
32 |
Intents.FLAGS.GUILD_PRESENCES, |
Intents.FLAGS.GUILD_PRESENCES, |
33 |
Intents.FLAGS.GUILD_MEMBERS, |
Intents.FLAGS.GUILD_MEMBERS, |
34 |
Intents.FLAGS.GUILD_BANS |
Intents.FLAGS.GUILD_BANS, |
35 |
|
Intents.FLAGS.GUILD_MESSAGE_REACTIONS, |
36 |
|
Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, |
37 |
] |
] |
38 |
}); |
}); |
39 |
|
|
44 |
this.spamFilter = new SpamFilter(); |
this.spamFilter = new SpamFilter(); |
45 |
this.antiRaid = new AntiRaid(); |
this.antiRaid = new AntiRaid(); |
46 |
this.messageFilter = new MessageFilter(); |
this.messageFilter = new MessageFilter(); |
47 |
|
this.afkEngine = new AFKEngine(); |
48 |
|
this.starboard = new Starboard(); |
49 |
this.boot(); |
this.boot(); |
50 |
} |
} |
51 |
|
|
52 |
boot() { |
boot() { |
53 |
|
const events = { |
54 |
|
MESSAGE_REACTION_ADD: 'messageReactionAdd', |
55 |
|
}; |
56 |
|
|
57 |
this.on('ready', () => { |
this.on('ready', () => { |
58 |
console.log("Logged in as " + this.client.user.tag); |
console.log("Logged in as " + this.client.user.tag); |
59 |
|
|
61 |
this.client.user.setActivity("over the server", { type: "WATCHING" }); |
this.client.user.setActivity("over the server", { type: "WATCHING" }); |
62 |
|
|
63 |
server(); |
server(); |
64 |
|
|
65 |
|
runTimeouts(); |
66 |
|
|
67 |
|
// setTimeoutv2(path.resolve(__dirname, '../queues/send.js'), 10000, "Hello world"); |
68 |
|
}); |
69 |
|
|
70 |
|
this.on('raw', async event => { |
71 |
|
if (!events.hasOwnProperty(event.t)) |
72 |
|
return; |
73 |
|
|
74 |
|
const { d: data } = event; |
75 |
|
const user = this.client.users.cache.find(i => i.id === data.user_id); |
76 |
|
const channel = this.client.channels.cache.find(i => i.id === data.channel_id) || await user.createDM(); |
77 |
|
|
78 |
|
if (channel.messages.cache.has(data.message_id)) |
79 |
|
return; |
80 |
|
|
81 |
|
const message = await channel.messages.fetch(data.message_id); |
82 |
|
|
83 |
|
const emojiKey = (data.emoji.id) ? `${data.emoji.name}:${data.emoji.id}` : data.emoji.name; |
84 |
|
const reaction = message.reactions.cache.get(emojiKey); |
85 |
|
|
86 |
|
this.client.emit(events[event.t], reaction, user); |
87 |
}); |
}); |
88 |
|
|
89 |
this.on('messageCreate', async (message) => { |
this.on('messageCreate', async (message) => { |
108 |
} |
} |
109 |
else if (valid && snippet !== undefined) { |
else if (valid && snippet !== undefined) { |
110 |
await message.channel.send({ |
await message.channel.send({ |
111 |
content: snippet.content |
content: snippet.content, |
112 |
|
files: snippet.files.map(f => { |
113 |
|
return { |
114 |
|
attachment: path.resolve(__dirname, '..', 'storage', f) |
115 |
|
} |
116 |
|
}) |
117 |
}); |
}); |
118 |
} |
} |
119 |
else if (valid && !has) { |
else if (valid && !has) { |
122 |
else if (valid && has && !allowed) { |
else if (valid && has && !allowed) { |
123 |
await this.commandManager.notAllowed(); |
await this.commandManager.notAllowed(); |
124 |
} |
} |
125 |
|
else if(!valid) { |
126 |
|
await this.afkEngine.start(message); |
127 |
|
} |
128 |
}); |
}); |
129 |
|
|
130 |
this.on("messageUpdate", async (oldMessage, newMessage) => { |
this.on("messageUpdate", async (oldMessage, newMessage) => { |
131 |
if (oldMessage.author.bot || oldMessage.content === newMessage.content) |
if (oldMessage.author.bot || !oldMessage.guild || oldMessage.channel.type == 'dm' || oldMessage.content === newMessage.content) |
132 |
return; |
return; |
133 |
|
|
134 |
|
let msg = await this.msg; |
135 |
|
await (this.msg = newMessage); |
136 |
|
|
137 |
|
await this.spamFilter.basic(newMessage); |
138 |
|
await this.messageFilter.start(newMessage, this.commandManager); |
139 |
|
|
140 |
await this.logger.logEdit(oldMessage, newMessage); |
await this.logger.logEdit(oldMessage, newMessage); |
141 |
|
await (this.msg = msg); |
142 |
}); |
}); |
143 |
|
|
144 |
|
this.on("messageReactionAdd", async (reaction, message) => { |
145 |
|
console.log('inside'); |
146 |
|
|
147 |
|
if (!reaction || !reaction.message || !message.guild || message.channel.type == 'dm') { |
148 |
|
return; |
149 |
|
} |
150 |
|
|
151 |
|
await (this.msg = reaction.message); |
152 |
|
await this.starboard.handle(reaction, message); |
153 |
|
}); |
154 |
|
|
155 |
this.on('guildBanAdd', async (ban) => { |
this.on('guildBanAdd', async (ban) => { |
156 |
console.log('test'); |
console.log('test'); |
163 |
}); |
}); |
164 |
|
|
165 |
this.on("messageDelete", async (message) => { |
this.on("messageDelete", async (message) => { |
166 |
if (message.author.bot) |
if (message.author.bot || !message.guild || message.channel.type == 'dm') |
167 |
return; |
return; |
168 |
|
|
169 |
await this.logger.logDelete(message); |
await this.logger.logDelete(message); |