const cheerio = require('cheerio'); const {defaultPermissions} = require('../util/default.json'); 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 {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, 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); var $ = cheerio.load(file); if ( process.env.READONLY ) createNotice($, 'readonly'); if ( action ) createNotice($, action, actionArgs); $('head').append( $('