@rcpooley/botyard 0.3.0 → 0.4.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.
- package/dist/botyard.js +58 -6
- package/dist/skill.js +1 -1
- package/package.json +1 -1
package/dist/botyard.js
CHANGED
|
@@ -180,19 +180,65 @@ const COMMANDS = [
|
|
|
180
180
|
{
|
|
181
181
|
name: 'thread',
|
|
182
182
|
group: 'Writing',
|
|
183
|
-
usage: 'thread <server> <channel> <name> [--from <message id>]',
|
|
184
|
-
summary: 'start a thread in a channel, from one of its messages with --from',
|
|
183
|
+
usage: 'thread <server> <channel> <name> [--from <message id>] [--add <user id>]...',
|
|
184
|
+
summary: 'start a thread in a channel, from one of its messages with --from, adding people with --add',
|
|
185
185
|
details: [
|
|
186
186
|
'Prints the new thread\'s id and name. Then send to it, read it and watch it by passing its id (or its name) wherever a channel goes: botyard send <server> <thread id> "...".',
|
|
187
187
|
'Names are 1-100 characters; words after <channel> are joined, so quotes are optional. Without --from it is a new public thread with no opening message.',
|
|
188
188
|
'For a new topic: post a short opening message in the channel, then botyard thread <server> <channel> <name> --from <that message id>, and keep the discussion in the thread. The channel then holds one entrance post per topic.',
|
|
189
189
|
'Threads close themselves after a week without messages; sending to one opens it again.',
|
|
190
|
+
"--add <user id> adds that person to the thread (repeat it, up to 10), silently: no ping. Discord notifies someone about a thread's messages only once they are a member of it, so add the humans who should hear about it. Someone Discord refuses (not in the server, say) is listed and the thread is still made. For a thread that already exists: botyard thread-add.",
|
|
190
191
|
],
|
|
191
192
|
args: 3,
|
|
192
193
|
rest: true,
|
|
193
194
|
run: async ([server, channel, name], opts) => {
|
|
194
|
-
const thread = await api(opts, 'POST', `${where(server, channel)}/threads`, {
|
|
195
|
-
|
|
195
|
+
const thread = await api(opts, 'POST', `${where(server, channel)}/threads`, {
|
|
196
|
+
name,
|
|
197
|
+
...(opts.from ? { message: opts.from } : {}),
|
|
198
|
+
...(opts.add?.length ? { members: opts.add } : {}),
|
|
199
|
+
});
|
|
200
|
+
if (opts.json)
|
|
201
|
+
return json(thread);
|
|
202
|
+
return [
|
|
203
|
+
`Started thread ${thread.id} ${thread.name}`,
|
|
204
|
+
...memberLines(thread.added ?? [], thread.failed ?? []),
|
|
205
|
+
`Send to it: botyard send ${quote(server)} ${thread.id} "..."`,
|
|
206
|
+
].join('\n');
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'thread-add',
|
|
211
|
+
group: 'Writing',
|
|
212
|
+
usage: 'thread-add <server> <thread> <user id>...',
|
|
213
|
+
summary: 'add people to an existing thread, silently',
|
|
214
|
+
details: [
|
|
215
|
+
'Adds each user id to the thread without pinging them. Discord notifies a person about a thread\'s messages only once they are a member of it, so this is how the humans who own a project get notified of the threads you start.',
|
|
216
|
+
'<thread> is its id or, while it is active, its name. A user id is a number (Discord: Settings > Advanced > Developer Mode, then right-click a person > Copy User ID).',
|
|
217
|
+
'Prints who was added and who Discord refused and why (someone not in the server, an archived or locked thread); exits 1 if any failed.',
|
|
218
|
+
],
|
|
219
|
+
args: 3,
|
|
220
|
+
many: true,
|
|
221
|
+
run: async ([server, thread, ...users], opts) => {
|
|
222
|
+
const added = [];
|
|
223
|
+
const failed = [];
|
|
224
|
+
for (const id of users) {
|
|
225
|
+
try {
|
|
226
|
+
await api(opts, 'PUT', `${where(server, thread)}/members/${seg(id)}`);
|
|
227
|
+
added.push(id);
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
failed.push({ id, error: e instanceof Error ? e.message : String(e) });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (opts.json) {
|
|
234
|
+
if (failed.length > 0)
|
|
235
|
+
process.exitCode = 1;
|
|
236
|
+
return json({ added, ...(failed.length > 0 ? { failed } : {}) });
|
|
237
|
+
}
|
|
238
|
+
const lines = memberLines(added, failed).join('\n');
|
|
239
|
+
if (failed.length > 0)
|
|
240
|
+
throw new Error(lines);
|
|
241
|
+
return lines;
|
|
196
242
|
},
|
|
197
243
|
},
|
|
198
244
|
{
|
|
@@ -375,6 +421,7 @@ function guide() {
|
|
|
375
421
|
"- If messages from others read as empty, the bot's Message Content intent is off; botyard prints a warning saying how to fix it. Only the bot's owner can, so pass it on to your human.",
|
|
376
422
|
"- To hear about new messages as they arrive, run `botyard watch` (in Claude Code, with the Monitor tool). With no options it covers every channel and thread; repeatable --server, --channel <server>#<channel> (with its threads) and --thread <server>#<thread> narrow it. Your own messages are left out. Don't poll with read.",
|
|
377
423
|
'- One topic, one thread: post a short opening message in the channel, then `botyard thread <server> <channel> <name> --from <that message id>`, and keep the discussion in the thread. A thread is used like a channel: pass its id (or name) wherever a <channel> goes.',
|
|
424
|
+
"- Discord notifies a person about a thread's messages only once they are a member of it. When you start a thread for a human's project, add them: `botyard thread ... --add <their user id>` (or `botyard thread-add <server> <thread> <user id>...` later). Adding does not ping them.",
|
|
378
425
|
'',
|
|
379
426
|
skillInstalled()
|
|
380
427
|
? `Claude Code skill: installed (${skillDir()}).`
|
|
@@ -384,6 +431,10 @@ function guide() {
|
|
|
384
431
|
function commandHelp(c) {
|
|
385
432
|
return [`botyard ${c.usage}`, '', `${c.summary[0].toUpperCase()}${c.summary.slice(1)}.`, ...(c.details ? ['', ...c.details] : [])].join('\n');
|
|
386
433
|
}
|
|
434
|
+
/** Who a thread's members call added, and who Discord refused. */
|
|
435
|
+
function memberLines(added, failed) {
|
|
436
|
+
return [...(added.length > 0 ? [`Added (silently, no ping): ${added.join(', ')}`] : []), ...failed.map((f) => `Could not add ${f.id}: ${f.error}`)];
|
|
437
|
+
}
|
|
387
438
|
function quote(s) {
|
|
388
439
|
return /^[\w#.-]+$/.test(s) ? s : `"${s.replace(/"/g, '\\"')}"`;
|
|
389
440
|
}
|
|
@@ -410,6 +461,7 @@ async function main(argv) {
|
|
|
410
461
|
channel: { type: 'string', multiple: true },
|
|
411
462
|
thread: { type: 'string', multiple: true },
|
|
412
463
|
from: { type: 'string' },
|
|
464
|
+
add: { type: 'string', multiple: true },
|
|
413
465
|
},
|
|
414
466
|
});
|
|
415
467
|
}
|
|
@@ -440,8 +492,8 @@ async function main(argv) {
|
|
|
440
492
|
process.stdout.write(commandHelp(command) + '\n');
|
|
441
493
|
return 0;
|
|
442
494
|
}
|
|
443
|
-
const given = command.rest && args.length > command.args ? [...args.slice(0, command.args - 1), args.slice(command.args - 1).join(' ')] : args;
|
|
444
|
-
if (given.length !== command.args) {
|
|
495
|
+
const given = command.many ? args : command.rest && args.length > command.args ? [...args.slice(0, command.args - 1), args.slice(command.args - 1).join(' ')] : args;
|
|
496
|
+
if (command.many ? given.length < command.args : given.length !== command.args) {
|
|
445
497
|
process.stderr.write(`botyard: usage: botyard ${command.usage}\n`);
|
|
446
498
|
return 2;
|
|
447
499
|
}
|
package/dist/skill.js
CHANGED
|
@@ -28,7 +28,7 @@ If messages from other people come back empty, the bot's Message Content intent
|
|
|
28
28
|
|
|
29
29
|
To follow Discord, don't poll: run \`botyard watch\` with the Monitor tool. It covers every channel and thread unless narrowed (\`botyard watch --help\`), and pushes each new message the moment it is posted, as one line.
|
|
30
30
|
|
|
31
|
-
For a new topic, post a short opening message, then start a thread from it with \`botyard thread\` and keep the discussion there.
|
|
31
|
+
For a new topic, post a short opening message, then start a thread from it with \`botyard thread\` and keep the discussion there. Add the humans who should hear about it (\`--add <user id>\`, or \`botyard thread-add\`): Discord only notifies thread members.
|
|
32
32
|
|
|
33
33
|
Never print, copy or store the key the CLI keeps; it handles authentication itself.
|
|
34
34
|
`;
|