pi-roundtable 0.50.1 → 0.50.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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.50.2] - 2026-11-16
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- A card answered after its turn stopped waiting now starts its late turn with the card's thread (`thread.parentId` and `parentKind`), as the live message there carries it, so a consumer that routes by thread, such as a forum post, handles the late answer the same way as a live one.
|
|
13
|
+
|
|
8
14
|
## [0.50.1] - 2026-11-16
|
|
9
15
|
|
|
10
16
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Channel,
|
|
3
|
+
ChannelType,
|
|
4
|
+
type Message,
|
|
5
|
+
MessageReferenceType,
|
|
6
|
+
} from "discord.js";
|
|
2
7
|
import type { InboundMessage } from "../contract/channels.ts";
|
|
3
8
|
import { channelKey } from "../contract/surface.ts";
|
|
4
9
|
import type { AttachmentRef } from "../domain/attachment.ts";
|
|
@@ -38,11 +43,10 @@ function referenceOf(referenced: Message, mention: RegExp) {
|
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
/** What a thread's parent is: a text channel, a forum, or something else (also a parent that cannot be read). */
|
|
41
|
-
async function threadOf(
|
|
42
|
-
|
|
46
|
+
export async function threadOf(
|
|
47
|
+
channel: Channel | null | undefined,
|
|
43
48
|
): Promise<InboundMessage["thread"] | undefined> {
|
|
44
|
-
|
|
45
|
-
if (!channel.isThread() || !channel.parentId) return undefined;
|
|
49
|
+
if (!channel?.isThread() || !channel.parentId) return undefined;
|
|
46
50
|
const parent =
|
|
47
51
|
channel.parent ??
|
|
48
52
|
(await channel.guild.channels.fetch(channel.parentId).catch(() => null));
|
|
@@ -87,7 +91,7 @@ export async function toInbound(
|
|
|
87
91
|
const roleIds = message.member
|
|
88
92
|
? [...message.member.roles.cache.keys()]
|
|
89
93
|
: undefined;
|
|
90
|
-
const thread = await threadOf(message);
|
|
94
|
+
const thread = await threadOf(message.channel);
|
|
91
95
|
return {
|
|
92
96
|
channel: channelKey("discord", message.channelId),
|
|
93
97
|
messageId: message.id,
|
|
@@ -169,6 +173,8 @@ export function lateAnswerMessage(turn: LateTurn): InboundMessage {
|
|
|
169
173
|
...(roles ? { authorRoleIds: roles } : {}),
|
|
170
174
|
...(turn.guildId ? { space: turn.guildId } : {}),
|
|
171
175
|
isDirect: turn.isDirect,
|
|
176
|
+
// The card's thread, as the live message there carries it, so a consumer routes it the same.
|
|
177
|
+
...(turn.thread ? { thread: turn.thread } : {}),
|
|
172
178
|
// Pressing the assistant's card speaks to it, as a mention does.
|
|
173
179
|
mentionsBot: true,
|
|
174
180
|
repliesToBot: true,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TextDisplayBuilder } from "discord.js";
|
|
2
|
+
import type { InboundMessage } from "../contract/channels.ts";
|
|
2
3
|
import type {
|
|
3
4
|
ApprovedBy,
|
|
4
5
|
OwnerQuestion,
|
|
@@ -45,6 +46,8 @@ export interface LateTurn {
|
|
|
45
46
|
/** The server the channel belongs to; absent in a direct message. */
|
|
46
47
|
guildId?: string;
|
|
47
48
|
isDirect: boolean;
|
|
49
|
+
/** The thread the card was posted in, and its parent; absent outside a thread. */
|
|
50
|
+
thread?: InboundMessage["thread"];
|
|
48
51
|
text: string;
|
|
49
52
|
}
|
|
50
53
|
|
|
@@ -56,6 +59,8 @@ export interface Answerer {
|
|
|
56
59
|
messageId?: string;
|
|
57
60
|
guildId?: string;
|
|
58
61
|
isDirect: boolean;
|
|
62
|
+
/** The thread the card was answered in, and its parent. */
|
|
63
|
+
thread?: InboundMessage["thread"];
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
/** One open card: how it looks, and how it ends. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { ChannelType, type Interaction } from "discord.js";
|
|
2
2
|
import { CARD_PREFIX, type CardPayload } from "./owner-cards.ts";
|
|
3
3
|
|
|
4
4
|
/** The primary owner of the cards' tests. */
|
|
@@ -53,6 +53,8 @@ export function press(
|
|
|
53
53
|
fields?: Record<string, string>;
|
|
54
54
|
/** Holds `deferUpdate` until it resolves, so the card can change while the press is in flight. */
|
|
55
55
|
gate?: Promise<void>;
|
|
56
|
+
/** The thread the card sits in: its parent and the parent's kind. */
|
|
57
|
+
thread?: { parentId: string; forum: boolean };
|
|
56
58
|
} = {},
|
|
57
59
|
) {
|
|
58
60
|
const replies: string[] = [];
|
|
@@ -74,6 +76,17 @@ export function press(
|
|
|
74
76
|
inGuild: () => true,
|
|
75
77
|
guildId: "300000000000000003",
|
|
76
78
|
message: { id: "400000000000000004" },
|
|
79
|
+
channel: options.thread
|
|
80
|
+
? {
|
|
81
|
+
isThread: () => true,
|
|
82
|
+
parentId: options.thread.parentId,
|
|
83
|
+
parent: {
|
|
84
|
+
type: options.thread.forum
|
|
85
|
+
? ChannelType.GuildForum
|
|
86
|
+
: ChannelType.GuildText,
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
: null,
|
|
77
90
|
user: { id: options.user ?? OWNER },
|
|
78
91
|
member: {
|
|
79
92
|
roles: { cache: new Map((options.roles ?? []).map((r) => [r, r])) },
|
|
@@ -12,6 +12,7 @@ import type { Logger } from "../kernel/log.ts";
|
|
|
12
12
|
import { type CardAudienceOptions, CardAudiences } from "./card-audience.ts";
|
|
13
13
|
import { CardCopies, copyReply, offeredCopy } from "./card-copies.ts";
|
|
14
14
|
import { DiscordOwners, discordUser } from "./discord-owners.ts";
|
|
15
|
+
import { threadOf } from "./inbound-message.ts";
|
|
15
16
|
import type { InteractionModule } from "./interaction-module.ts";
|
|
16
17
|
import {
|
|
17
18
|
answerDeferred,
|
|
@@ -289,6 +290,7 @@ export class OwnerCards implements InteractionModule {
|
|
|
289
290
|
user: by.user,
|
|
290
291
|
...(by.guildId ? { guildId: by.guildId } : {}),
|
|
291
292
|
isDirect: by.isDirect,
|
|
293
|
+
...(by.thread ? { thread: by.thread } : {}),
|
|
292
294
|
text,
|
|
293
295
|
});
|
|
294
296
|
} catch (error) {
|
|
@@ -382,11 +384,13 @@ export class OwnerCards implements InteractionModule {
|
|
|
382
384
|
return true;
|
|
383
385
|
}
|
|
384
386
|
const user = discordUser(interaction);
|
|
387
|
+
const thread = await threadOf(interaction.channel);
|
|
385
388
|
const by: Answerer = {
|
|
386
389
|
user,
|
|
387
390
|
...(interaction.message ? { messageId: interaction.message.id } : {}),
|
|
388
391
|
...(interaction.guildId ? { guildId: interaction.guildId } : {}),
|
|
389
392
|
isDirect: !interaction.inGuild(),
|
|
393
|
+
...(thread ? { thread } : {}),
|
|
390
394
|
};
|
|
391
395
|
// A menu pick or Submit is deferred before the audience is looked up, which may take a while.
|
|
392
396
|
if (
|