windsor-bot 0.1.14 → 0.1.16

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/dist/bot.js CHANGED
@@ -3,7 +3,7 @@ import { formatScheduleDate, generateIcon, getNextOccurrence, parseRecurringSche
3
3
  import { Commands } from './commands/index.js';
4
4
  import { getCurrentConfig, reconcileChannels } from './config.js';
5
5
  import { formatTimestamp } from './printer.js';
6
- import { printJob, PrinterUnavailableError } from './printing/index.js';
6
+ import { isPrinterUnavailableError, printJob } from './printing/index.js';
7
7
  import { logEvent, status } from './server.js';
8
8
  import { Reaction } from './reactions.js';
9
9
  const MAX_MESSAGE_CHARS = 800;
@@ -448,7 +448,7 @@ export function createWindsorBot() {
448
448
  logEvent('print', `Printed immediate message from ${message.author.username}`);
449
449
  }
450
450
  catch (err) {
451
- if (err instanceof PrinterUnavailableError) {
451
+ if (isPrinterUnavailableError(err)) {
452
452
  await reactSafe(message, Reaction.waiting);
453
453
  enqueuePendingPrint(message, () => handleImmediatePrint(message, config, false, true));
454
454
  logEvent('info', `Printer unavailable for immediate message from ${message.author.username}`);
@@ -518,7 +518,7 @@ export function createWindsorBot() {
518
518
  logEvent('print', `Printed accumulating list (${lines.length} items)`);
519
519
  }
520
520
  catch (err) {
521
- if (err instanceof PrinterUnavailableError) {
521
+ if (isPrinterUnavailableError(err)) {
522
522
  await reactSafe(triggerMessage, Reaction.waiting);
523
523
  enqueuePendingPrint(triggerMessage, () => handleAccumulatingPrint(triggerMessage, config, allMessages, true));
524
524
  logEvent('info', `Printer unavailable for accumulating list in #${triggerMessage.channelId}`);
@@ -661,7 +661,7 @@ export function createWindsorBot() {
661
661
  result = await cmd.invoke(args, ctx);
662
662
  }
663
663
  catch (err) {
664
- if (err instanceof PrinterUnavailableError) {
664
+ if (isPrinterUnavailableError(err)) {
665
665
  await reactSafe(message, Reaction.waiting);
666
666
  enqueuePendingPrint(message, () => handleOnDemand(message, true));
667
667
  logEvent('info', `Printer unavailable for command '${commandName}'`);
@@ -1,9 +1,12 @@
1
+ import { isPrinterUnavailableError } from "../printing/index.js";
1
2
  export function tryExecCommandFunction(func) {
2
3
  return async function (cmd, ctx) {
3
4
  try {
4
5
  return await func(cmd, ctx);
5
6
  }
6
7
  catch (err) {
8
+ if (isPrinterUnavailableError(err))
9
+ throw err;
7
10
  return {
8
11
  kind: "fail",
9
12
  reason: `${err}`
@@ -8,7 +8,7 @@ export class PrinterUnavailableError extends Error {
8
8
  this.name = 'PrinterUnavailableError';
9
9
  }
10
10
  }
11
- function isUnavailableError(error) {
11
+ export function isPrinterUnavailableError(error) {
12
12
  let current = error;
13
13
  for (let depth = 0; depth < 4 && current; depth++) {
14
14
  if (!(current instanceof Error))
@@ -53,7 +53,7 @@ export async function printJob(job) {
53
53
  }
54
54
  }
55
55
  catch (error) {
56
- if (isUnavailableError(error)) {
56
+ if (isPrinterUnavailableError(error)) {
57
57
  throw new PrinterUnavailableError(error instanceof Error ? error.message : String(error));
58
58
  }
59
59
  throw error;
package/dist/server.js CHANGED
@@ -65,8 +65,13 @@ async function readPackageVersion() {
65
65
  return packageJson.version;
66
66
  }
67
67
  async function updateGlobalBot() {
68
- await execFileAsync('npm', ['install', '-g', 'windsor-bot@latest']);
69
- const { stdout } = await execFileAsync('npm', ['root', '-g']);
68
+ // GUI-launched processes may not inherit the shell PATH where npm is installed.
69
+ const npmEnv = {
70
+ ...process.env,
71
+ PATH: [dirname(process.execPath), process.env.PATH].filter(Boolean).join(process.platform === 'win32' ? ';' : ':'),
72
+ };
73
+ await execFileAsync('npm', ['install', '-g', 'windsor-bot@latest'], { env: npmEnv });
74
+ const { stdout } = await execFileAsync('npm', ['root', '-g'], { env: npmEnv });
70
75
  const packageJsonPath = join(stdout.trim(), 'windsor-bot', 'package.json');
71
76
  const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf8'));
72
77
  if (typeof packageJson.version !== 'string')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windsor-bot",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Self-hosted Discord bot automation for household list and todo printing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",