windsor-bot 0.2.0 → 0.2.2
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 +4 -1
- package/dist/server.js +20 -9
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -94,7 +94,10 @@ async function removeReactionSafe(message, emoji) {
|
|
|
94
94
|
}
|
|
95
95
|
async function reactSafe(message, emoji, clearThinking = true) {
|
|
96
96
|
try {
|
|
97
|
-
|
|
97
|
+
// Retries can encounter the same pending reaction repeatedly while offline.
|
|
98
|
+
if (!message.reactions.cache.get(emoji)?.me) {
|
|
99
|
+
await message.react(emoji);
|
|
100
|
+
}
|
|
98
101
|
if (emoji !== Reaction.thinking && clearThinking) {
|
|
99
102
|
await removeReactionSafe(message, Reaction.thinking);
|
|
100
103
|
}
|
package/dist/server.js
CHANGED
|
@@ -65,27 +65,38 @@ async function readPackageVersion() {
|
|
|
65
65
|
return packageJson.version;
|
|
66
66
|
}
|
|
67
67
|
async function updateGlobalBot() {
|
|
68
|
-
const
|
|
68
|
+
const npmCandidates = [
|
|
69
69
|
process.env['npm_execpath'],
|
|
70
70
|
join(dirname(process.execPath), '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
71
|
+
join(dirname(process.execPath), 'npm'),
|
|
71
72
|
'/usr/local/lib/node_modules/npm/bin/npm-cli.js',
|
|
72
73
|
'/opt/homebrew/lib/node_modules/npm/bin/npm-cli.js',
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
'/usr/lib/node_modules/npm/bin/npm-cli.js',
|
|
75
|
+
'/usr/share/nodejs/npm/bin/npm-cli.js',
|
|
76
|
+
'/usr/local/bin/npm',
|
|
77
|
+
'/opt/homebrew/bin/npm',
|
|
78
|
+
'/usr/bin/npm',
|
|
79
|
+
]
|
|
80
|
+
.filter((candidate) => Boolean(candidate))
|
|
81
|
+
.map(candidate => ({
|
|
82
|
+
path: candidate.endsWith('.js') ? process.execPath : candidate,
|
|
83
|
+
args: candidate.endsWith('.js') ? [candidate] : [],
|
|
84
|
+
}));
|
|
85
|
+
let npmCommand;
|
|
86
|
+
for (const candidate of npmCandidates) {
|
|
76
87
|
try {
|
|
77
|
-
await access(candidate);
|
|
78
|
-
|
|
88
|
+
await access(candidate.path);
|
|
89
|
+
npmCommand = candidate;
|
|
79
90
|
break;
|
|
80
91
|
}
|
|
81
92
|
catch {
|
|
82
93
|
// Try the next known npm installation location.
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
|
-
if (!
|
|
96
|
+
if (!npmCommand)
|
|
86
97
|
throw new Error('Unable to locate npm');
|
|
87
|
-
const
|
|
88
|
-
const runNpm = (args) => execFileAsync(
|
|
98
|
+
const npm = npmCommand;
|
|
99
|
+
const runNpm = (args) => execFileAsync(npm.path, [...npm.args, ...args], { env: process.env });
|
|
89
100
|
await runNpm(['install', '-g', 'windsor-bot@latest']);
|
|
90
101
|
const { stdout } = await runNpm(['root', '-g']);
|
|
91
102
|
const packageJsonPath = join(stdout.trim(), 'windsor-bot', 'package.json');
|