-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
64 lines (52 loc) · 2.07 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
const jet = require('./classes/client');
const HandleMessage = require('./messageHandlers');
const IntervalProcess = require('./intervalProcess');
const FetchMutes = require('./tools/fetchMutes');
jet.configure();
jet.on('ready', () => {
const { size } = jet.guilds;
const postfix = size > 1 ? 'guilds' : 'guild';
jet.user.setActivity(`j:help in ${size} ${postfix}`);
FetchMutes();
setInterval(IntervalProcess, 5000);
console.log(" jet's ready");
});
jet.on('message', (message) => {
const { content, author } = message;
const { caller } = jet.config;
if (author.bot || !content.startsWith(caller)) return;
const param = content.substring(caller.length).trim();
HandleMessage(message, param);
});
jet.on('messageReactionAdd', (reaction, user) => {
const slideTab = jet.slideTabs.get(user.id);
if (!slideTab) return;
if (reaction.message.id !== slideTab.message.id || !slideTab.emotes.includes(reaction.emoji.name)) return;
clearTimeout(slideTab.timer);
slideTab.timer = setTimeout(slideTab.remove, 30000);
slideTab.scroll(reaction.emoji.name);
if (reaction.emoji.name !== '❌') reaction.remove(user.id).catch();
});
jet.on('messageDelete', (message) => {
const searchFunc = (e) => e.message.id === message.id;
const slideTab = jet.slideTabs.find(searchFunc);
if (!slideTab) return;
clearTimeout(slideTab.timer);
jet.slideTabs.delete(slideTab.userID);
});
jet.on('guildCreate', async (guild) => {
const { size } = jet.guilds;
try {
const { owner } = guild;
await owner.send('thanks for adding me to your server');
} catch (e) {}
const postfix = size > 1 ? 'guilds' : 'guild';
jet.user.setActivity(`j:help in ${size} ${postfix}`);
});
jet.on('guildDelete', (guild) => {
const { size } = jet.guilds;
const postfix = size > 1 ? 'guilds' : 'guild';
jet.user.setActivity(`j:help in ${size} ${postfix}`);
});
jet.login(jet.config.SUPER_SECRET_TOKEN);