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.
Files changed (2) hide show
  1. package/lib/grinder.js +36 -16
  2. 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
- await Promise.all(batch.map(async (acc, idx) => {
2765
- if (idx > 0) await new Promise(r => setTimeout(r, 100 + Math.floor(Math.random() * 500)));
2766
- console.log(` [${i + idx + 1}] starting: ${acc.label || acc.id}`);
2767
- const worker = new AccountWorker(acc, i + idx);
2768
- workers.push(worker);
2769
- workerMap.set(acc.id, worker);
2770
- await worker.start();
2771
- console.log(` [${i + idx + 1}] done: ${acc.label || acc.id}`);
2772
- if (worker._tokenInvalid) {
2773
- console.log(` [${i + idx + 1}] FAIL - invalid token: ${acc.label || acc.id}`);
2774
- } else if (worker.channel) {
2775
- console.log(` [${i + idx + 1}] OK - ${worker.username}`);
2776
- } else {
2777
- console.log(` [${i + idx + 1}] TIMEOUT`);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dankgrinder",
3
- "version": "8.21.0",
3
+ "version": "8.23.0",
4
4
  "description": "Dank Memer automation engine — grind coins while you sleep",
5
5
  "bin": {
6
6
  "dankgrinder": "bin/dankgrinder.js"