MCPcopy Index your code
hub / github.com/AnswerOverflow/AnswerOverflow / findServerByIdWithChannels

Function findServerByIdWithChannels

packages/core/src/server.ts:122–145  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

120}
121
122export async function findServerByIdWithChannels(id: string) {
123 const found = await db.query.dbServers.findFirst({
124 where: eq(dbServers.id, id),
125 with: {
126 channels: {
127 where: inArray(dbChannels.type, Array.from(ALLOWED_ROOT_CHANNEL_TYPES)),
128 },
129 },
130 });
131 if (!found) return null;
132 return {
133 ...addFlagsToServer(found),
134 channels: found.channels
135 .map((c) => addFlagsToChannel(c))
136 // first forums, then announcements, then text
137 .sort((a, b) => {
138 if (a.type === ChannelType.GuildForum) return -1;
139 if (b.type === ChannelType.GuildForum) return 1;
140 if (a.type === ChannelType.GuildAnnouncement) return -1;
141 if (b.type === ChannelType.GuildAnnouncement) return 1;
142 return 0;
143 }),
144 };
145}
146
147export type ServerWithChannels = ReturnType<typeof findServerByIdWithChannels>;
148

Callers 1

dashboard.tsFile · 0.90

Calls 2

addFlagsToServerFunction · 0.90
addFlagsToChannelFunction · 0.90

Tested by

no test coverage detected