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

Function getDiscordUser

packages/core/src/auth.ts:708–724  ·  view source on GitHub ↗
(opts: DiscordApiCallOpts)

Source from the content-addressed store, hash-verified

706 }
707
708 export async function getDiscordUser(opts: DiscordApiCallOpts) {
709 const client = await Cache.getRedisClient();
710 const cachedUser = await client.get(
711 getDiscordUserRedisKey(opts.accessToken),
712 );
713 if (cachedUser) {
714 try {
715 return zUserSchema.parse(JSON.parse(cachedUser));
716 } catch (e) {
717 console.log(e);
718 }
719 }
720 const data = await discordApiFetch('/users/@me', opts);
721 const parsed = zUserSchema.parse(await data.json());
722 await updateCachedDiscordUser(opts.accessToken, parsed);
723 return parsed;
724 }
725
726 export async function isRefreshTokenBeingUsed(
727 refreshToken: string,

Callers 2

linkAccountFunction · 0.85
identifyAccountFunction · 0.85

Calls 4

getDiscordUserRedisKeyFunction · 0.85
discordApiFetchFunction · 0.85
updateCachedDiscordUserFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected