forked from TahaGorme/slashy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
393 lines (281 loc) · 11.9 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
var version = "1.3";
//Version 1.3
const axios = require('axios');
const cors = require('cors');
const path = require('path');
axios.get('https://raw.githubusercontent.com/TahaGorme/slashy/main/index.js')
.then(function (response) {
var d = response.data;
if (d.match(/Version [0-9]*\.[0-9]+/)) {
console.log("Version " + version)
if (d.match(/Version [0-9]*\.[0-9]+/)[0].replace("Version ", "") !== version) {
console.log("There is a new version " + d.match(/Version [0-9]*\.[0-9]+/)[0].replace("Version ", "") + " available. Please update. https://github.com/TahaGorme/slashy")
}
// console.log(d.replace("Version ",""));
}
// console.log(.replace("Version ",""));
})
.catch(function (error) {
console.log(error);
})
.finally(function () {
});
process.on('unhandledRejection', (reason, p) => {
console.log(' [Anti Crash] >> Unhandled Rejeciton/Catch');
console.log(reason, p)
})
process.on('uncaughtException', (e, o) => {
console.log(' [Anti Crash] >> Uncaught Exception/Catch');
console.log(e, o)
})
process.on('uncaughtExceptionMonitor', (err, origin) => {
console.log(' [AntiCrash] >> Uncaught Exception/Catch (MONITOR)');
console.log(err, origin);
});
process.on('multipleResolves', (type, promise, reason) => {
console.log(' [AntiCrash] >> Multiple Resolves');
console.log(type, promise, reason);
});
var bank = 0;
var purse = 0;
var net = 0;
const config = require('./config.json');
var express = require('express');
var app = express();
app.set('view engine', 'ejs');
app.enable("trust proxy");
app.use(cors());
// set the view engine to ejs
app.get("/", async (req, res) => {
res.render(path.resolve("./static"), {
// "progressValue": pr
});
});
app.get("/api", async (req, res) => {
res.json({
"bank": bank,
"purse": purse,
"net": net
})
});
app.listen(7500);
console.log('Server is listening on port 7500');
start()
async function start() {
for (var i = 0; i < config.tokens.length; i++) {
await doEverything(config.tokens[i]);
}
}
async function doEverything(token) {
var channel;
const { Webhook } = require('discord-webhook-node');
const { Client, Discord } = require('discord.js-selfbot-v13');
const chalk = require('chalk');
const figlet = require('figlet');
const client = new Client({ checkUpdate: false, readyStatus: false });
const botid = "270904126974590976";
var commandsUsed = [];
var ongoingCommand = false;
const hook = new Webhook(config.webhook);
const fs = require('fs-extra')
async function findAnswer(question) {
const trivia = await fs.readJson('./trivia.json')
for (let i = 0; i < trivia.database.length; i++) {
if (trivia.database[i].question.includes(question)) {
return trivia.database[i].correct_answer;
}
}
}
client.on('ready', async () => {
client.user.setStatus('invisible');
console.log(
chalk.yellow(
figlet.textSync('Slashy', { horizontalLayout: 'full' })
)
);
console.log(chalk.green(`Logged in as ${chalk.cyanBright(client.user.tag)}`));
channel = client.channels.cache.get(config.channel_id);
if (!channel) return;
console.log("Playing Dank Memer in " + channel.name)
hook.send("Started. Playing Dank Memer in <#" + channel.id + ">");
await channel.sendSlash(botid, "balance")
main(channel)
})
client.on('messageCreate', async (message) => {
if (!channel) return;
if (message.flags.has('EPHEMERAL')) return;
if (message.author.id === botid) {
if (message.embeds[0].title && message.embeds[0].title === "Pending Confirmation") {
highLowRandom(message, 1)
console.log(chalk.yellow("Sold all sellable items."))
}
if (!message.embeds[0].description) return;
if (message.embeds[0].title && message.embeds[0].title.includes(client.user.tag + "'s balance")) {
purse = message.embeds[0].description.split("\n")[0].replace("**Wallet**: ", "");
bank = message.embeds[0].description.split("\n")[1].replace("**Bank**: ", "");
net = message.embeds[0].description.split("\n")[2].replace("**Net**: ", "");
// console.log(coins)
// console.log(bank)
// console.log(net)
}
if (commandsUsed.includes('search') && message.embeds[0].description.includes("Where do you want to search?")) {
clickRandomButton(message, 0)
}
if (commandsUsed.includes('crime') && message.embeds[0].description.includes("What crime do you want to commit?")) {
clickRandomButton(message, 0)
}
if (commandsUsed.includes('postmemes') && message.embeds[0].description.includes("Pick a meme to post to the internet")) {
clickRandomButton(message, 0)
}
if (commandsUsed.includes('trivia') && message.embeds[0].description.includes(" seconds to answer*")) {
var time = message.embeds[0].description
var question = message.embeds[0].description.replace(/\*/g, '').split("\n")[0].split('"')[0];
let answer = await findAnswer(question);
selectTriviaAnswers(message, answer)
}
if (commandsUsed.includes('highlow') && message.embeds[0].description.includes("I just chose a secret number between 1 and 100.")) {
var a = message.embeds[0].description.replace("I just chose a secret number between 1 and 100.", "");
var b = a.replace("Is the secret number *higher* or *lower* than **", "");
var c = parseInt(b.replace("**?", "").trim())
if (c > 50) {
highLowRandom(message, 0)
}
if (c <= 50) {
highLowRandom(message, 2)
}
}
}
});
client.login(token);
async function main(channel) {
var a = randomInteger(1000, 5000);
var b = randomInteger(30 * 1000, 90 * 1000);
var c = randomInteger(10 * 1000 * 60, 80 * 60 * 1000);
randomCommand(channel)
if (config.autoDeposit && randomInteger(0, 100) === 2) {
await channel.sendSlash(botid, "deposit", "max")
console.log(chalk.yellow("Deposited all coins in the bank."))
}
if (randomInteger(0, 20) === 3) {
await channel.sendSlash(botid, "balance")
}
if (config.autoSell && randomInteger(0, 4) === 100) {
await channel.sendSlash(botid, "sell all")
}
if (randomInteger(0, 250) == 50) {
console.log("\x1b[34m", "Taking a break for " + b / 1000 + " seconds.")
hook.send("Taking a break for " + b / 1000 + " seconds.")
setTimeout(async function () {
main(channel)
}, b);
} else if (randomInteger(0, 1400) == 400) {
console.log("\x1b[35m", "Sleeping for " + c / 1000 / 60 + " minutes.")
hook.send("Sleeping for " + c / 1000 / 60 + " minutes.")
setTimeout(async function () {
main(channel)
}, c);
} else {
setTimeout(async function () {
main(channel)
}, a);
}
}
function random(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
async function randomCommand(channel) {
let command = config.commands[random(0, config.commands.length - 1)];
if (commandsUsed.includes(command)) return;
console.log("\x1b[0m", "Using command " + command)
commandsUsed.push(command)
ongoingCommand = true;
if (command === "beg") {
await channel.sendSlash(botid, "beg")
handleCommand(command, "beg", 51000, 55000)
} else if (command === "fish") {
await channel.sendSlash(botid, "fish")
handleCommand(command, "fish", 46000, 50000)
} else if (command === "hunt") {
await channel.sendSlash(botid, "hunt")
handleCommand(command, "hunt", 46000, 50000)
} else if (command === "dig") {
await channel.sendSlash(botid, "dig")
handleCommand(command, "dig", 46000, 50000)
} else if (command === "search") {
await channel.sendSlash(botid, "search")
handleCommand(command, "search", 36000, 42000)
} else if (command === "crime") {
await channel.sendSlash(botid, "crime")
handleCommand(command, "crime", 49000, 55000)
} else if (command === "postmemes") {
await channel.sendSlash(botid, "postmemes")
handleCommand(command, "postmemes", 53000, 64000)
} else if (command === "highlow") {
await channel.sendSlash(botid, "highlow")
handleCommand(command, "highlow", 53000, 64000)
} else if (command === "trivia") {
await channel.sendSlash(botid, "trivia")
handleCommand(command, "trivia", 6500, 10000)
}
}
function removeAllInstances(arr, item) {
for (var i = arr.length; i--;) {
if (arr[i] === item) arr.splice(i, 1);
}
}
async function handleCommand(command, com, delaymin, delaymax) {
if (command === com) {
ongoingCommand = false;
setTimeout(() => {
removeAllInstances(commandsUsed, com);
}
, delaymin)
}
}
async function clickRandomButton(message, rows) {
setTimeout(async () => {
const components = message.components[randomInteger(0, rows)]?.components;
const len = components?.length;
let customId;
if (len == NaN) return;
customId = components[Math.floor(Math.random() * len)].customId;
return await message.clickButton(customId);
}, randomInteger(500, 1500))
}
async function highLowRandom(message, number) {
setTimeout(async () => {
const components = message.components[0]?.components;
const len = components?.length;
let customId;
if (len == NaN) return;
customId = components[number].customId;
return await message.clickButton(customId);
}, randomInteger(500, 1500))
}
async function selectTriviaAnswers(message, ans) {
setTimeout(async () => {
var flag = false;
const components = message.components[0]?.components;
const len = components?.length;
let customId;
if (len == NaN) return;
for (var i = 0; i < components.length; i++) {
if (components[i].label.includes(ans)) {
customId = components[i].customId;
flag = true;
return await message.clickButton(customId);
}
}
if (!flag || ans === undefined) {
customId = components[randomInteger(0, 3)].customId;
return await message.clickButton(customId);
}
}, randomInteger(500, 5500))
}
function randomInteger(min, max) {
if (min == max) {
return min;
}
return Math.floor(Math.random() * (max - min + 1)) + min;
}
}