dankgrinder 8.113.0 → 8.114.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.
@@ -50,10 +50,9 @@ async function waitForEditedMessage(channel, messageId, baselineText, timeoutMs
50
50
  * @param {object} [opts.client]
51
51
  * @returns {Promise<{result: string, coins: number}>}
52
52
  */
53
- async function runGeneric({ channel, waitForDankMemer, cmdString, cmdName, client, useSlash, prefix = 'pls' }) {
53
+ async function runGeneric({ channel, waitForDankMemer, cmdString, cmdName, client, useSlash = false, prefix = 'pls' }) {
54
54
  LOG.cmd(`${c.white}${c.bold}${cmdString}${c.reset}`);
55
- // cmdString = "pls farm view" or "/farm view"
56
- // Build slash command: strip prefix → "farm view" → sendSlash('farm view')
55
+ // Strip prefix from cmdString to get just "command subcmd"
57
56
  const slashName = cmdString
58
57
  .replace(/^pls\s+/, '')
59
58
  .replace(/^\/\s*/, '')
@@ -65,20 +65,21 @@ async function sendCommand(channel, commandName, opts = {}) {
65
65
  args = [],
66
66
  } = opts;
67
67
 
68
+ // Only use slash if explicitly enabled
68
69
  if (useSlash && channel?.sendSlash) {
69
70
  try {
70
- // sendSlash takes botId, commandName, ...args
71
71
  await channel.sendSlash(DANK_MEMER_ID, commandName, ...args);
72
72
  return;
73
73
  } catch (e) {
74
- LOG.warn(`[sendSlash] ${commandName} failed: ${e.message} falling back to text`);
74
+ const msg = e instanceof Error ? e.message : String(e);
75
+ LOG.warn(`[sendSlash] ${commandName} failed: ${msg} — falling back to text`);
75
76
  }
76
77
  }
77
78
 
78
- // Fallback: text command
79
+ // Fallback: always use pls prefix unless slash is explicitly enabled
79
80
  const textCmd = args.length > 0
80
- ? `${prefix} ${commandName} ${args.join(' ')}`
81
- : `${prefix} ${commandName}`;
81
+ ? `pls ${commandName} ${args.join(' ')}`
82
+ : `pls ${commandName}`;
82
83
  await channel.send(textCmd);
83
84
  }
84
85
 
package/lib/grinder.js CHANGED
@@ -1096,7 +1096,7 @@ class AccountWorker {
1096
1096
  }
1097
1097
 
1098
1098
  async checkBalance(silent = false) {
1099
- const prefix = this.account.use_slash ? '/' : 'pls';
1099
+ const prefix = !!this.account.use_slash ? '/' : 'pls';
1100
1100
  const sentAt = Date.now();
1101
1101
 
1102
1102
  const looksLikeBalance = (t) => {
@@ -1107,7 +1107,7 @@ class AccountWorker {
1107
1107
  };
1108
1108
 
1109
1109
  // Fast path: send command, wait 3s, read from rawLogger
1110
- if (this.account.use_slash && this.channel?.sendSlash) {
1110
+ if (!!this.account.use_slash && this.channel?.sendSlash) {
1111
1111
  await this.channel.sendSlash(DANK_MEMER_ID, 'balance').catch(() => this.channel.send('/balance'));
1112
1112
  } else {
1113
1113
  await this.channel.send(`${prefix} bal`);
@@ -1126,7 +1126,7 @@ class AccountWorker {
1126
1126
  // If rawLogger didn't capture it, fall back to waitForDankMemer
1127
1127
  if (!text || !looksLikeBalance(text)) {
1128
1128
  let response = await this.waitForDankMemer(8000);
1129
- if (!response && this.account.use_slash) {
1129
+ if (!response && !!this.account.use_slash) {
1130
1130
  await this.channel.send('pls bal');
1131
1131
  response = await this.waitForDankMemer(8000);
1132
1132
  }
@@ -1401,7 +1401,7 @@ class AccountWorker {
1401
1401
  cmdName === 'crime' ? safeParseJSON(this.account.crime_answers, []) : [],
1402
1402
  adventureAnswers: AccountWorker.ADVENTURE_ANSWERS,
1403
1403
  useSlash: !!this.account.use_slash,
1404
- prefix: this.account.use_slash ? '/' : 'pls',
1404
+ prefix: !!this.account.use_slash ? '/' : 'pls',
1405
1405
  betAmount: this._questBetOverride || (['blackjack'].includes(cmdName) ? bjBet : gambBet),
1406
1406
  accountId: this.account.id,
1407
1407
  redis,
@@ -2458,7 +2458,7 @@ class AccountWorker {
2458
2458
  } else {
2459
2459
  this._questBetOverride = quest.bet || null;
2460
2460
  }
2461
- const prefix = this.account.use_slash ? '/' : 'pls';
2461
+ const prefix = !!this.account.use_slash ? '/' : 'pls';
2462
2462
 
2463
2463
  if (quest.loseTarget) {
2464
2464
  // Loss-target quest: keep playing until cumulative losses >= loseTarget
@@ -2742,7 +2742,7 @@ class AccountWorker {
2742
2742
  await new Promise(r => setTimeout(r, minGap - timeSinceLastCmd));
2743
2743
  }
2744
2744
 
2745
- const prefix = this.account.use_slash ? '/' : 'pls';
2745
+ const prefix = !!this.account.use_slash ? '/' : 'pls';
2746
2746
  this.setStatus(formatCommandName(item.cmd));
2747
2747
 
2748
2748
  // Report "running" to dashboard
@@ -2869,7 +2869,7 @@ class AccountWorker {
2869
2869
  if (!this.busy) {
2870
2870
  this.log('info', 'Alert detected → running alert');
2871
2871
  this.busy = true;
2872
- const prefix = this.account.use_slash ? '/' : 'pls';
2872
+ const prefix = !!this.account.use_slash ? '/' : 'pls';
2873
2873
  this.runCommand('alert', prefix).finally(() => { this.busy = false; });
2874
2874
  }
2875
2875
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dankgrinder",
3
- "version": "8.113.0",
3
+ "version": "8.114.0",
4
4
  "description": "Dank Memer automation engine — grind coins while you sleep",
5
5
  "bin": {
6
6
  "dankgrinder": "bin/dankgrinder.js"