import DiscordOauth2 from 'discord-oauth2'; const oauth = new DiscordOauth2(); /** * Retrieves an access & refresh token from the discord api * @param code The authorization code from the callback */ export const createTokenByCode = (code: string) => oauth.tokenRequest({ grantType: "authorization_code", scope: "identify guilds", clientId: process.env.DC_CLIENT, clientSecret: process.env.DC_SECRET, redirectUri: process.env.DC_REDIRECT_URI, code }); /** * Gets user information from the discord api * @param token The access token of the user */ export const getUser = (token: string) => oauth.getUser(token);