const cheerio = require('cheerio'); const {defaultPermissions} = require('../util/default.json'); const Lang = require('./i18n.js'); const allLangs = Lang.allLangs().names; const {oauth, settingsData, addWidgets, createNotice} = require('./util.js'); const forms = { settings: require('./settings.js').get, verification: require('./verification.js').get, rcscript: require('./rcscript.js').get, slash: require('./slash.js').get }; 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} theme - The display theme * @param {import('./util.js').UserSession} userSession - The user session * @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, theme, userSession, reqURL, action, actionArgs) { reqURL.pathname = reqURL.pathname.replace( /^(\/(?:guild\/\d+(?:\/(?:settings|verification|rcscript|slash)(?:\/(?:\d+|new|notice))?)?)?)(?:\/.*)?$/, '$1' ); var args = reqURL.pathname.split('/'); var settings = settingsData.get(userSession.user_id); if ( reqURL.searchParams.get('owner') && process.env.owner.split('|').includes(userSession.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); if ( theme === 'light' ) $('html').addClass('theme-light'); $('