windsor-bot 0.1.1 → 0.1.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/README.md +7 -0
- package/dist/index.js +6 -7
- package/package.json +1 -1
- package/src/index.ts +7 -7
package/README.md
CHANGED
|
@@ -118,6 +118,13 @@ npm run dev
|
|
|
118
118
|
|
|
119
119
|
Then open `http://localhost:8080` to use the web control panel.
|
|
120
120
|
|
|
121
|
+
When installed globally, run `windsor-bot` from the directory containing
|
|
122
|
+
`windsor.config.json`, or set `WINDSOR_CONFIG_PATH` to its full path:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
WINDSOR_CONFIG_PATH=/path/to/windsor.config.json windsor-bot
|
|
126
|
+
```
|
|
127
|
+
|
|
121
128
|
The control panel is a Preact app served by the diagnostics server and can:
|
|
122
129
|
|
|
123
130
|
1. Show runtime bot status and recent events.
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { loadConfig
|
|
2
|
+
import { loadConfig } from './config.js';
|
|
3
3
|
import { logEvent, startDiagnosticsServer, setDiscordChannels, setRestartHandler, setRefreshChannelsHandler } from './server.js';
|
|
4
4
|
import { createWindsorBot, checkScheduledTasks } from './bot.js';
|
|
5
5
|
import { ChannelType } from 'discord.js';
|
|
6
|
-
const config =
|
|
6
|
+
const { config } = await loadConfig();
|
|
7
7
|
startDiagnosticsServer(config.diagnosticsPort);
|
|
8
8
|
let bot = null;
|
|
9
9
|
let startInFlight = false;
|
|
10
|
-
async function startBot() {
|
|
10
|
+
async function startBot(cfg) {
|
|
11
11
|
if (startInFlight)
|
|
12
12
|
return;
|
|
13
|
-
const cfg = getCurrentConfig();
|
|
14
13
|
if (!cfg.discordToken) {
|
|
15
14
|
logEvent('info', 'No Discord token configured. Visit the control panel to set up.');
|
|
16
15
|
return;
|
|
@@ -51,8 +50,8 @@ export async function restartBot() {
|
|
|
51
50
|
bot = null;
|
|
52
51
|
}
|
|
53
52
|
setDiscordChannels([]);
|
|
54
|
-
await loadConfig();
|
|
55
|
-
await startBot();
|
|
53
|
+
const { config } = await loadConfig();
|
|
54
|
+
await startBot(config);
|
|
56
55
|
}
|
|
57
56
|
// Recurring task checker
|
|
58
57
|
setInterval(() => {
|
|
@@ -82,4 +81,4 @@ async function refreshChannels() {
|
|
|
82
81
|
logEvent('info', `Refreshed ${channels.length} Discord channels`);
|
|
83
82
|
}
|
|
84
83
|
setRefreshChannelsHandler(refreshChannels);
|
|
85
|
-
await startBot();
|
|
84
|
+
await startBot(config);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { loadConfig
|
|
2
|
+
import { loadConfig } from './config.ts';
|
|
3
3
|
import { logEvent, startDiagnosticsServer, setDiscordChannels, setRestartHandler, setRefreshChannelsHandler } from './server.ts';
|
|
4
4
|
import { createWindsorBot, checkScheduledTasks } from './bot.ts';
|
|
5
5
|
import { ChannelType } from 'discord.js';
|
|
6
|
+
import type { WindsorConfig } from './types.ts';
|
|
6
7
|
|
|
7
|
-
const config =
|
|
8
|
+
const { config } = await loadConfig();
|
|
8
9
|
|
|
9
10
|
startDiagnosticsServer(config.diagnosticsPort);
|
|
10
11
|
|
|
11
12
|
let bot: ReturnType<typeof createWindsorBot> | null = null;
|
|
12
13
|
let startInFlight = false;
|
|
13
14
|
|
|
14
|
-
async function startBot(): Promise<void> {
|
|
15
|
+
async function startBot(cfg: WindsorConfig): Promise<void> {
|
|
15
16
|
if (startInFlight) return;
|
|
16
|
-
const cfg = getCurrentConfig();
|
|
17
17
|
if (!cfg.discordToken) {
|
|
18
18
|
logEvent('info', 'No Discord token configured. Visit the control panel to set up.');
|
|
19
19
|
return;
|
|
@@ -58,8 +58,8 @@ export async function restartBot(): Promise<void> {
|
|
|
58
58
|
bot = null;
|
|
59
59
|
}
|
|
60
60
|
setDiscordChannels([]);
|
|
61
|
-
await loadConfig();
|
|
62
|
-
await startBot();
|
|
61
|
+
const { config } = await loadConfig();
|
|
62
|
+
await startBot(config);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// Recurring task checker
|
|
@@ -95,4 +95,4 @@ async function refreshChannels(): Promise<void> {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
setRefreshChannelsHandler(refreshChannels);
|
|
98
|
-
await startBot();
|
|
98
|
+
await startBot(config);
|