-
Notifications
You must be signed in to change notification settings - Fork 82
/
index.js
248 lines (214 loc) · 9.19 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
const fetch = require('node-fetch'),
fs = require('fs'),
Discord = require('discord.js'),
request = require('request'),
client = new Discord.Client(),
XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest,
admins = ["yourid", "yourid", "yourid"],
config = {
"yourroleid": 1500,
"yourroleid": 75,
"yourroleid": 50,
"yourroleid": 20,
"yourroleid": 10,
"yourroleid": 5
}
var tokens = fs.readFileSync('./tokens.txt', 'utf-8');
tokens = tokens.split(/\s+/).filter(t => !t.startsWith("#"))
client.on('ready', async () => {
console.log(`${client.user.tag} is ready !`)
console.log(`Loaded ${tokens.length} tokens !`)
})
client.on('message', async (message) => {
const prefix = "/";
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if (command === "help") {
message.channel.send(new Discord.MessageEmbed()
.addFields({
name: "Followers Booster",
value: `\`${prefix}tfollow <twitch username>\``,
inline: true
}, {
name: "Help Page",
value: `\`${prefix}help\``,
inline: true
}, {
name: "Bot Latency",
value: `\`${prefix}ping\``,
inline: true
}, {
name: "Nuke (Mod Only)",
value: `\`${prefix}nuke\``,
inline: true
}, {
name: "Eval (Mod Only)",
value: `\`${prefix}eval <code>\``,
inline: true
})
.setColor("GREEN")
.setFooter(message.guild.name, message.guild.iconURL({
dynamic: true
}))
)
}
if (command === "ping") {
message.channel.send(new Discord.MessageEmbed()
.setDescription(`My ping is **${client.ws.ping}ms** !`)
.setColor("GREEN")
.setFooter(message.guild.name, message.guild.iconURL({
dynamic: true
}))
)
}
if (command === "nuke") {
const position = message.channel.position
const channel = await message.channel.clone();
message.channel.delete();
channel.setPosition(position)
}
if (command === "eval" && admins.includes(message.author.id)) {
const content = message.content.split(" ").slice(1).join(" ");
const result = new Promise(async (resolve) => resolve(eval(content)));
return result.then(async (output) => {
if (typeof output !== "string") {
output = require("util").inspect(output, {
depth: 0
});
}
if (output.includes(client.token)) {
output = output.replace(client.token, "T0K3N");
}
message.channel.send(output, {
code: "js"
});
}).catch((err) => {
err = err.toString();
if (err.includes(client.token)) {
err = err.replace(client.token, "T0K3N");
}
message.channel.send(err, {
code: "js"
});
console.log(err)
});
}
if (command === "tfollow") {
let twitchID = "";
if (admins.includes(message.author.id)) {
if (!args[0]) return message.channel.send(new Discord.MessageEmbed().setColor('RED').setDescription("You must specify a twitch username !"))
var roleID = Object.entries(config).find(([key, value]) => message.member.roles.cache.sort((a, b) => a.position - b.position).find(x => x.id === key))
if (!roleID) roleID = [null, 0]
await getUser(args[0]).then((res) => {
if (res._total === 0) {
return message.channel.send(new Discord.MessageEmbed().setColor('RED').setDescription("You must specify **valid** a twitch username !"))
} else {
twitchID = res.users[0]._id
}
})
let number = args[1] ? parseInt(args[1]) : roleID[1] + 25
follow(twitchID, number).then((cool) => {
const channel = client.channels.cache.find(c => c.name === "proofs");
if (channel) channel.send(new Discord.MessageEmbed().setColor("GREEN").setAuthor(message.author.username, message.author.displayAvatarURL({
format: 'png',
dynamic: true,
size: 1024
}))
.setFooter(message.guild.name, message.guild.iconURL({
dynamic: true
}))
.setDescription(`Successfully added **${number}** followers to \`${args[0]}\` (Twitch ID: \`${twitchID}\`)\n\nCheck out [${args[0]}'s twitch channel](https://twitch.tv/${args[0]}/)`)).then((msg) => {
msg.react("<:verified:825762203419541524>")
})
})
message.channel.send(new Discord.MessageEmbed().setColor('GREEN').setDescription(`Adding **${number}** followers to \`${args[0]}\` !`))
} else if (!admins.includes(message.author.id)) {
if (message.channel.id === client.channels.cache.find(c => c.name === "chat").id) return message.delete();
var roleID = Object.entries(config).find(([key, value]) => message.member.roles.cache.sort((a, b) => a.position - b.position).find(x => x.id === key))
if (!args[0]) return message.channel.send(new Discord.MessageEmbed().setColor('RED').setDescription("You must specify a twitch username !"))
let number = 25
if (roleID) {
number = number + roleID[1]
}
await getUser(args[0]).then((res) => {
if (res._total === 0) {
return message.channel.send(new Discord.MessageEmbed().setColor('RED').setDescription("You must specify **valid** a twitch username !"))
} else {
twitchID = res.users[0]._id
}
})
message.channel.send(new Discord.MessageEmbed().setColor('GREEN').setDescription(`Adding **${number}** followers to \`${args[0]}\` !`))
follow(twitchID, number).then((cool) => {
const channel = client.channels.cache.find(c => c.name === "proofs");
if (channel) channel.send(new Discord.MessageEmbed().setColor("GREEN").setAuthor(message.author.username, message.author.displayAvatarURL({
format: 'png',
dynamic: true,
size: 1024
}))
.setFooter(message.guild.name, message.guild.iconURL({
dynamic: true
}))
.setDescription(`Successfully added **${number}** followers to \`${args[0]}\` (Twitch ID: \`${twitchID}\`)\n\nCheck out [${args[0]}'s twitch channel](https://twitch.tv/${args[0]}/)`)).then((msg) => {
msg.react("<:verified:825762203419541524>")
})
})
}
}
})
function getUser(username) {
return fetch(`https://api.twitch.tv/kraken/users?login=${username}`, {
method: "GET",
headers: {
'Client-ID': "ymd9sjdyrpi8kz8zfxkdf5du04m649",
"Authorization": "OAuth wukbrnwp5f6uo4barxkzfpkacyugob",
'Accept': 'application/vnd.twitchtv.v5+json'
}
}).then(async (res) => res.json())
};
async function follow(twitchID, number) {
return new Promise(async (resolve, reject) => {
let done = 0
for (var i = 0; i < number; i++) {
let res = await sendRequest(twitchID, tokens[i]);
done++
}
while (i === number) {
return resolve(true)
}
})
}
async function sendRequest(userid, token) {
return new Promise(async (resolve, reject) => {
var data = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"` + userid + `"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"3efee1acda90efdff9fef6e6b4a29213be3ee490781c5b54469717b6131ffdfe"}}}]
`;
const options = {
url: 'https://gql.twitch.tv/gql',
headers: {
"Authorization": 'OAuth ' + token,
"Client-Id": 'kimne78kx3ncx6brgo4mv6wki5h1ko',
"Content-Type": "application/json"
},
body: data
};
request.post(options, (err, res, body) => {
if (err) {
return console.log(`Invalid twitch token`);
}
console.log(JSON.parse(body));
resolve(true)
});
})
}
client.on("guildMemberAdd", async (member) => {
const channels = ["rewards", "farm-twitch"]
for (let i = 0; i < channels.length; i++) {
const channel = client.channels.cache.find(c => c.name === channels[i])
if (channel) channel.send(`${member}, **Check out this channel !**`).then(async (msg) => {
msg.delete({
timeout: 5000
})
})
}
})
client.login("Token")