dankgrinder 8.21.0 → 8.22.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 +33 -16
  2. package/package.json +1 -1
package/lib/grinder.js CHANGED
@@ -9,6 +9,14 @@ const {
9
9
  } = require('./structures');
10
10
  const PKG_VERSION = require('../package.json').version;
11
11
 
12
+ // Catch silent Discord client errors
13
+ process.on('unhandledRejection', (reason) => {
14
+ process.stdout.write(`[UNHANDLED REJECTION] ${reason?.message || reason}\n`);
15
+ });
16
+ process.on('uncaughtException', (err) => {
17
+ process.stdout.write(`[UNCAUGHT] ${err.message}\n`);
18
+ });
19
+
12
20
  // ── Memory-Optimized Client Factory ──────────────────────────
13
21
  // zlib-sync enables WS transport compression (~40% bandwidth reduction).
14
22
  // With all caches zeroed + sweepers, each client uses ~80-120KB.
@@ -2423,6 +2431,7 @@ class AccountWorker {
2423
2431
  }
2424
2432
 
2425
2433
  async start() {
2434
+ process.stdout.write(`[WORKER START] ${this.account.label || this.account.id}\n`);
2426
2435
  if (!this.account.discord_token) { this.log('error', 'No token'); return; }
2427
2436
  if (!this.account.channel_id) { this.log('error', 'No channel'); return; }
2428
2437
 
@@ -2761,22 +2770,30 @@ async function start(apiKey, apiUrl, opts = {}) {
2761
2770
  for (let i = 0; i < accounts.length; i += BATCH_SIZE) {
2762
2771
  if (shutdownCalled) break;
2763
2772
  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
- }));
2773
+ try {
2774
+ await Promise.all(batch.map(async (acc, idx) => {
2775
+ try {
2776
+ if (idx > 0) await new Promise(r => setTimeout(r, 100 + Math.floor(Math.random() * 500)));
2777
+ console.log(` [${i + idx + 1}] starting: ${acc.label || acc.id}`);
2778
+ const worker = new AccountWorker(acc, i + idx);
2779
+ workers.push(worker);
2780
+ workerMap.set(acc.id, worker);
2781
+ await worker.start();
2782
+ console.log(` [${i + idx + 1}] done: ${acc.label || acc.id}`);
2783
+ if (worker._tokenInvalid) {
2784
+ console.log(` [${i + idx + 1}] FAIL - invalid token: ${acc.label || acc.id}`);
2785
+ } else if (worker.channel) {
2786
+ console.log(` [${i + idx + 1}] OK - ${worker.username}`);
2787
+ } else {
2788
+ console.log(` [${i + idx + 1}] TIMEOUT`);
2789
+ }
2790
+ } catch (e) {
2791
+ console.log(` [${i + idx + 1}] ERROR: ${e.message}`);
2792
+ }
2793
+ }));
2794
+ } catch (e) {
2795
+ console.log(`BATCH ERROR: ${e.message}`);
2796
+ }
2780
2797
  if (i + BATCH_SIZE < accounts.length) await new Promise(r => setTimeout(r, randomLoginGap()));
2781
2798
  hintGC();
2782
2799
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dankgrinder",
3
- "version": "8.21.0",
3
+ "version": "8.22.0",
4
4
  "description": "Dank Memer automation engine — grind coins while you sleep",
5
5
  "bin": {
6
6
  "dankgrinder": "bin/dankgrinder.js"