diff --git a/server/routes/discord.ts b/server/routes/discord.ts index 4674a7e80..59ade5702 100644 --- a/server/routes/discord.ts +++ b/server/routes/discord.ts @@ -62,7 +62,7 @@ const getAccessToken = async (userId: string) => { if (tokenSet === undefined) { return undefined; } - if (Date.now() > tokenSet.expires_in) { + if (Date.now() > tokenSet.expires_at!) { const token: TokenSet = await fetch(`${BASE_DISCORD_URI}/oauth2/token`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, @@ -74,6 +74,7 @@ const getAccessToken = async (userId: string) => { }).then((res) => res.json()); token.expires_at = Date.now() + tokenSet.expires_in * 1e3; store.set(userId, token); + return token.access_token; } return tokenSet.access_token; };