Skip to content

Commit d601afb

Browse files
committed
Revert "feat: more sophisticated tree"
This reverts commit dbea045.
1 parent dbea045 commit d601afb

File tree

2 files changed

+255
-289
lines changed

2 files changed

+255
-289
lines changed

src/commands/family.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,32 @@ export async function execute(
125125

126126
await interaction.deferReply();
127127

128-
const treeBuffer = await FamilyTreeRenderer.generateTree(
129-
targetUser,
130-
interaction.client,
131-
interaction.guildId!,
132-
);
128+
const spouseIds = await FamilyManager.getSpouses(targetUser.id);
129+
const spouses = await Promise.all(
130+
spouseIds.map((id) => interaction.client.users.fetch(id).catch(() => null)),
131+
).then(users => users.filter((u): u is NonNullable<typeof u> => u !== null));
132+
133+
const childrenIds = await FamilyManager.getChildren(targetUser.id);
134+
const children = await Promise.all(
135+
childrenIds.map((id) => interaction.client.users.fetch(id).catch(() => null)),
136+
).then(users => users.filter((u): u is NonNullable<typeof u> => u !== null));
137+
138+
const parentIds = await FamilyManager.getParents(targetUser.id);
139+
const parents = await Promise.all(
140+
parentIds.map((id) => interaction.client.users.fetch(id).catch(() => null)),
141+
).then(users => users.filter((u): u is NonNullable<typeof u> => u !== null));
142+
143+
const siblingIds = await FamilyManager.getSiblings(targetUser.id);
144+
const siblings = await Promise.all(
145+
siblingIds.map((id) => interaction.client.users.fetch(id).catch(() => null)),
146+
).then(users => users.filter((u): u is NonNullable<typeof u> => u !== null));
147+
148+
const treeBuffer = await FamilyTreeRenderer.generateTree(targetUser, {
149+
spouses,
150+
parents,
151+
children,
152+
siblings,
153+
});
133154

134155
const attachment = new AttachmentBuilder(treeBuffer, {
135156
name: "family-tree.png",

0 commit comments

Comments
 (0)