const cheerio = require('cheerio'); const {defaultPermissions} = require('../util/default.json'); const Lang = require('./i18n.js'); const allLangs = Lang.allLangs().names; const {settingsData, createNotice} = require('./util.js'); const forms = { settings: require('./settings.js').get, verification: require('./verification.js').get, rcscript: require('./rcscript.js').get }; const DiscordOauth2 = require('discord-oauth2'); const oauth = new DiscordOauth2( { clientId: process.env.bot, clientSecret: process.env.secret, redirectUri: process.env.dashboard } ); const file = require('fs').readFileSync('./dashboard/index.html'); /** * Let a user view settings * @param {import('http').ServerResponse} res - The server response * @param {import('./i18n.js')} dashboardLang - The user language. * @param {String} state - The user state * @param {URL} reqURL - The used url * @param {String} [action] - The action the user made * @param {String[]} [actionArgs] - The arguments for the action */ function dashboard_guilds(res, dashboardLang, state, reqURL, action, actionArgs) { reqURL.pathname = reqURL.pathname.replace( /^(\/(?:guild\/\d+(?:\/(?:settings|verification|rcscript)(?:\/(?:\d+|new))?)?)?)(?:\/.*)?$/, '$1' ); var args = reqURL.pathname.split('/'); args = reqURL.pathname.split('/'); var settings = settingsData.get(state); if ( reqURL.searchParams.get('owner') && process.env.owner.split('|').includes(settings.user.id) ) { args[0] = 'owner'; } dashboardLang = new Lang(...dashboardLang.fromCookie, settings.user.locale, dashboardLang.lang); res.setHeader('Content-Language', [dashboardLang.lang]); var $ = cheerio.load(file); $('html').attr('lang', dashboardLang.lang); $('