diff --git a/server/modules/authentication/discord/authentication.js b/server/modules/authentication/discord/authentication.js index 3c0af63a..1a090199 100644 --- a/server/modules/authentication/discord/authentication.js +++ b/server/modules/authentication/discord/authentication.js @@ -21,6 +21,7 @@ function hasRoles(memberRoles, authRoles) { module.exports = { init (passport, conf) { + const discord = new DiscordOauth2() passport.use(conf.key, new DiscordStrategy({ clientID: conf.clientId, @@ -32,7 +33,6 @@ module.exports = { }, async (req, accessToken, refreshToken, profile, cb) => { try { if (conf.roles) { - const discord = new DiscordOauth2() const memberRoles = await discord.getGuildMember(accessToken, conf.guildId) const authRoles = conf.roles.split(); const { roles } = await discord.getGuildMember(accessToken, conf.guildId);