-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
115 lines (108 loc) · 3.31 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
const config = require('./config.json');
const Discord = require('discord.js');
const spook = new Discord.Client({
messageCacheMaxSize: 20,
messageCacheLifetime: 10,
messageSweepInterval: 60,
disabledEvents: [
'GUILD_UPDATE',
'GUILD_MEMBER_ADD',
'GUILD_MEMBER_REMOVE',
'GUILD_MEMBER_UPDATE',
'GUILD_MEMBERS_CHUNK',
'GUILD_ROLE_CREATE',
'GUILD_ROLE_DELETE',
'GUILD_ROLE_UPDATE',
'GUILD_BAN_ADD',
'GUILD_BAN_REMOVE',
'CHANNEL_UPDATE',
'CHANNEL_PINS_UPDATE',
'MESSAGE_DELETE',
'MESSAGE_UPDATE',
'MESSAGE_DELETE_BULK',
'MESSAGE_REACTION_ADD',
'MESSAGE_REACTION_REMOVE',
'MESSAGE_REACTION_REMOVE_ALL',
'USER_UPDATE',
'USER_NOTE_UPDATE',
'USER_SETTINGS_UPDATE',
'PRESENCE_UPDATE',
'VOICE_STATE_UPDATE',
'TYPING_START',
'VOICE_SERVER_UPDATE',
'RELATIONSHIP_ADD',
'RELATIONSHIP_REMOVE',
],
});
spook.on('ready', () => {
const mode = config.monster ? 'Active' : 'Deactive';
console.log(`Sp00kbot ready. [Monster mode: ${mode}]`);
});
spook.on('message', async (msg) => {
if (msg.author.id !== '755580145078632508') return;
//if (msg.guild.id !== config.sp00kguild) return;
if (!config.sp00kguild.includes(msg.guild.id)) return;
if (msg.embeds[0].description.includes('h!trick')) {
const MonsterName = msg.embeds[0].image.url.slice(41, -4);
console.log(`${MonsterName} Spawn at ${msg.guild.name}`);
switch (config.monster) {
case true:
await sleep(config.delay)
msg.channel.send('h!treat');
const checkmessage1 = await msg.channel.fetchMessage(msg.id);
if (
checkmessage1.embeds[0].description.includes(`<@${spook.user.id}>`)
) {
console.log(`Success spooking ${MonsterName} at ${msg.guild.name}`);
} else
console.log(`Failed spooking ${MonsterName} at ${msg.guild.name}`);
break;
case false:
await sleep(config.delay)
msg.channel.send('h!trick');
const checkmessage2 = await msg.channel.fetchMessage(msg.id);
if (
checkmessage2.embeds[0].description.includes(`<@${spook.user.id}>`)
) {
console.log(`Success spooking ${MonsterName} at ${msg.guild.name}`);
} else
console.log(`Failed spooking ${MonsterName} at ${msg.guild.name}`);
break;
}
return;
}
if (msg.embeds[0].description.includes('h!treat')) {
const MonsterName = msg.embeds[0].image.url.slice(41, -4);
console.log(`${MonsterName} Spawn at ${msg.guild.name}`);
switch (config.monster) {
case true:
await sleep(config.delay)
await msg.channel.send('h!trick');
const checkmessage1 = await msg.channel.fetchMessage(msg.id);
if (
checkmessage1.embeds[0].description.includes(`<@${spook.user.id}>`)
) {
console.log(`Success spooking ${MonsterName} at ${msg.guild.name}`);
} else
console.log(`Failed spooking ${MonsterName} at ${msg.guild.name}`);
break;
case false:
await sleep(config.delay)
await msg.channel.send('h!treat');
const checkmessage2 = await msg.channel.fetchMessage(msg.id);
if (
checkmessage2.embeds[0].description.includes(`<@${spook.user.id}>`)
) {
console.log(`Success spooking ${MonsterName} at ${msg.guild.name}`);
} else
console.log(`Failed spooking ${MonsterName} at ${msg.guild.name}`);
break;
}
return;
}
});
function sleep(ms) {
console.log("sleeping")
return new Promise(resolve => setTimeout(resolve, ms));
}
spook.login(config.token);