import { readFileSync } from 'fs'; import { load as cheerioLoad } from 'cheerio'; import { forms } from './functions.js'; import Lang from './i18n.js'; import { oauth, enabledOAuth2, settingsData, addWidgets, createNotice } from './util.js'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); const {defaultPermissions} = require('../util/default.json'); const allLangs = Lang.allLangs().names; const file = readFileSync('./dashboard/index.html'); /** * Let a user view settings * @param {import('http').ServerResponse} res - The server response * @param {import('./i18n.js').default} 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 */ export default function dashboard_guilds(res, dashboardLang, theme, userSession, reqURL, action, actionArgs) { reqURL.pathname = reqURL.pathname.replace( /^(\/(?:user|guild\/\d+(?:\/(?:settings|verification|rcscript)(?:\/(?:\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 $ = cheerioLoad(file); $('html').attr('lang', dashboardLang.lang); if ( theme === 'light' ) $('html').addClass('theme-light'); $('