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"); |
const AFKEngine = require("./AFKEngine"); |
15 |
|
const Starboard = require("./Starboard"); |
16 |
|
|
17 |
class App { |
class App { |
18 |
constructor(rootdir) { |
constructor(rootdir) { |
30 |
Intents.FLAGS.DIRECT_MESSAGE_TYPING, |
Intents.FLAGS.DIRECT_MESSAGE_TYPING, |
31 |
Intents.FLAGS.GUILD_PRESENCES, |
Intents.FLAGS.GUILD_PRESENCES, |
32 |
Intents.FLAGS.GUILD_MEMBERS, |
Intents.FLAGS.GUILD_MEMBERS, |
33 |
Intents.FLAGS.GUILD_BANS |
Intents.FLAGS.GUILD_BANS, |
34 |
|
Intents.FLAGS.GUILD_MESSAGE_REACTIONS, |
35 |
|
Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, |
36 |
] |
] |
37 |
}); |
}); |
38 |
|
|
44 |
this.antiRaid = new AntiRaid(); |
this.antiRaid = new AntiRaid(); |
45 |
this.messageFilter = new MessageFilter(); |
this.messageFilter = new MessageFilter(); |
46 |
this.afkEngine = new AFKEngine(); |
this.afkEngine = new AFKEngine(); |
47 |
|
this.starboard = new Starboard(); |
48 |
this.boot(); |
this.boot(); |
49 |
} |
} |
50 |
|
|
51 |
boot() { |
boot() { |
52 |
|
const events = { |
53 |
|
MESSAGE_REACTION_ADD: 'messageReactionAdd', |
54 |
|
}; |
55 |
|
|
56 |
this.on('ready', () => { |
this.on('ready', () => { |
57 |
console.log("Logged in as " + this.client.user.tag); |
console.log("Logged in as " + this.client.user.tag); |
58 |
|
|
62 |
server(); |
server(); |
63 |
}); |
}); |
64 |
|
|
65 |
|
this.on('raw', async event => { |
66 |
|
if (!events.hasOwnProperty(event.t)) |
67 |
|
return; |
68 |
|
|
69 |
|
const { d: data } = event; |
70 |
|
const user = this.client.users.cache.find(i => i.id === data.user_id); |
71 |
|
const channel = this.client.channels.cache.find(i => i.id === data.channel_id) || await user.createDM(); |
72 |
|
|
73 |
|
if (channel.messages.cache.has(data.message_id)) |
74 |
|
return; |
75 |
|
|
76 |
|
const message = await channel.messages.fetch(data.message_id); |
77 |
|
|
78 |
|
const emojiKey = (data.emoji.id) ? `${data.emoji.name}:${data.emoji.id}` : data.emoji.name; |
79 |
|
const reaction = message.reactions.cache.get(emojiKey); |
80 |
|
|
81 |
|
this.client.emit(events[event.t], reaction, user); |
82 |
|
}); |
83 |
|
|
84 |
this.on('messageCreate', async (message) => { |
this.on('messageCreate', async (message) => { |
85 |
if (message.author.bot || !message.guild || message.channel.type == 'dm') { |
if (message.author.bot || !message.guild || message.channel.type == 'dm') { |
86 |
return; |
return; |
129 |
await this.logger.logEdit(oldMessage, newMessage); |
await this.logger.logEdit(oldMessage, newMessage); |
130 |
}); |
}); |
131 |
|
|
132 |
|
this.on("messageReactionAdd", async (reaction, message) => { |
133 |
|
console.log('inside'); |
134 |
|
|
135 |
|
if (!reaction || !reaction.message) { |
136 |
|
return; |
137 |
|
} |
138 |
|
|
139 |
|
await (this.msg = reaction.message); |
140 |
|
await this.starboard.handle(reaction, message); |
141 |
|
}); |
142 |
|
|
143 |
this.on('guildBanAdd', async (ban) => { |
this.on('guildBanAdd', async (ban) => { |
144 |
console.log('test'); |
console.log('test'); |