MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / checkIntegrations

Function checkIntegrations

packages/integration-discord/src/utils/linen.ts:52–73  ·  view source on GitHub ↗
(externalId: string[], botId: number)

Source from the content-addressed store, hash-verified

50}
51
52export async function checkIntegrations(externalId: string[], botId: number) {
53 return await prisma.accounts
54 .findMany({
55 select: { discordAuthorizations: true, discordServerId: true },
56 where: { discordServerId: { in: externalId } },
57 })
58 .then((accounts) => {
59 return accounts.filter((account) => {
60 const sortByAsc = account.discordAuthorizations.sort(
61 (a, b) => a.createdAt.getTime() - b.createdAt.getTime()
62 );
63 const lastAuth = sortByAsc.pop();
64 if (lastAuth) {
65 if (lastAuth.scope === `linen-bot-${botId}`) {
66 return true;
67 } else if (botId === 1 && !lastAuth.customBot) {
68 return true;
69 }
70 }
71 });
72 });
73}
74
75export async function findChannelById(id: string) {
76 return await prisma.channels.findUnique({ where: { id } });

Callers 1

cleanUpIntegrationsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected