dankgrinder 8.21.0 → 8.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/grinder.js +36 -16
- package/package.json +1 -1
package/lib/grinder.js
CHANGED
|
@@ -9,6 +9,17 @@ const {
|
|
|
9
9
|
} = require('./structures');
|
|
10
10
|
const PKG_VERSION = require('../package.json').version;
|
|
11
11
|
|
|
12
|
+
// Global shutdown flag
|
|
13
|
+
let shutdownCalled = false;
|
|
14
|
+
|
|
15
|
+
// Catch silent Discord client errors
|
|
16
|
+
process.on('unhandledRejection', (reason) => {
|
|
17
|
+
process.stdout.write(`[UNHANDLED REJECTION] ${reason?.message || reason}\n`);
|
|
18
|
+
});
|
|
19
|
+
process.on('uncaughtException', (err) => {
|
|
20
|
+
process.stdout.write(`[UNCAUGHT] ${err.message}\n`);
|
|
21
|
+
});
|
|
22
|
+
|
|
12
23
|
// ── Memory-Optimized Client Factory ──────────────────────────
|
|
13
24
|
// zlib-sync enables WS transport compression (~40% bandwidth reduction).
|
|
14
25
|
// With all caches zeroed + sweepers, each client uses ~80-120KB.
|
|
@@ -2423,6 +2434,7 @@ class AccountWorker {
|
|
|
2423
2434
|
}
|
|
2424
2435
|
|
|
2425
2436
|
async start() {
|
|
2437
|
+
process.stdout.write(`[WORKER START] ${this.account.label || this.account.id}\n`);
|
|
2426
2438
|
if (!this.account.discord_token) { this.log('error', 'No token'); return; }
|
|
2427
2439
|
if (!this.account.channel_id) { this.log('error', 'No channel'); return; }
|
|
2428
2440
|
|
|
@@ -2761,22 +2773,30 @@ async function start(apiKey, apiUrl, opts = {}) {
|
|
|
2761
2773
|
for (let i = 0; i < accounts.length; i += BATCH_SIZE) {
|
|
2762
2774
|
if (shutdownCalled) break;
|
|
2763
2775
|
const batch = accounts.slice(i, Math.min(i + BATCH_SIZE, accounts.length));
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2776
|
+
try {
|
|
2777
|
+
await Promise.all(batch.map(async (acc, idx) => {
|
|
2778
|
+
try {
|
|
2779
|
+
if (idx > 0) await new Promise(r => setTimeout(r, 100 + Math.floor(Math.random() * 500)));
|
|
2780
|
+
console.log(` [${i + idx + 1}] starting: ${acc.label || acc.id}`);
|
|
2781
|
+
const worker = new AccountWorker(acc, i + idx);
|
|
2782
|
+
workers.push(worker);
|
|
2783
|
+
workerMap.set(acc.id, worker);
|
|
2784
|
+
await worker.start();
|
|
2785
|
+
console.log(` [${i + idx + 1}] done: ${acc.label || acc.id}`);
|
|
2786
|
+
if (worker._tokenInvalid) {
|
|
2787
|
+
console.log(` [${i + idx + 1}] FAIL - invalid token: ${acc.label || acc.id}`);
|
|
2788
|
+
} else if (worker.channel) {
|
|
2789
|
+
console.log(` [${i + idx + 1}] OK - ${worker.username}`);
|
|
2790
|
+
} else {
|
|
2791
|
+
console.log(` [${i + idx + 1}] TIMEOUT`);
|
|
2792
|
+
}
|
|
2793
|
+
} catch (e) {
|
|
2794
|
+
console.log(` [${i + idx + 1}] ERROR: ${e.message}`);
|
|
2795
|
+
}
|
|
2796
|
+
}));
|
|
2797
|
+
} catch (e) {
|
|
2798
|
+
console.log(`BATCH ERROR: ${e.message}`);
|
|
2799
|
+
}
|
|
2780
2800
|
if (i + BATCH_SIZE < accounts.length) await new Promise(r => setTimeout(r, randomLoginGap()));
|
|
2781
2801
|
hintGC();
|
|
2782
2802
|
}
|