dashboard-core/theme/dbd-soft-ui/index.js

48 lines
2 KiB
JavaScript
Raw Normal View History

2023-06-22 19:36:52 +05:00
const consolePrefix = `${"[".blue}${"dbd-soft-ui".yellow}${"]".blue} `;
const Keyv = require("keyv");
const path = require("path");
const { readFileSync } = require("fs");
2023-06-19 14:21:58 +05:00
module.exports = (themeConfig = {}) => {
2023-06-22 19:36:52 +05:00
return {
themeCodename: "softui",
viewsPath: path.join(__dirname, "/views"),
staticPath: path.join(__dirname, "/views/src"),
themeConfig: {
...themeConfig,
defaultLocales: require("./locales.js"),
},
messages: {
error: {
addonLicense: `${consolePrefix}${"Failed to initialise {{ADDON}}.\nThe license this addon was installed with does not match your current discord-dashboard license.".cyan}`,
},
success: {
addonLoaded: `${consolePrefix}${"Successfully loaded {{ADDON}}.".cyan}`,
},
},
embedBuilderComponent: readFileSync(path.join(__dirname, "/embedBuilderComponent.txt"), "utf8"),
init: async (app, config) => {
if (!config?.useTheme404) return console.log(`${consolePrefix}${"You need to set useTheme404 to true in your DBD config otherwise Soft-UI will not work correctly!\n\nDashboard has not fully initialised due to this. Pages will 404!".red}`);
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
const db = new Keyv(themeConfig.dbdriver || "sqlite://" + path.join(__dirname, "/database.sqlite"));
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
db.on("error", (err) => {
console.log("Connection Error", err);
process.exit();
});
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
themeConfig = { ...themeConfig, defaultLocales: require("./locales.js") };
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
require("./utils/functions/errorHandler")(config, themeConfig, db);
require("./utils/functions/settingsPage")(config, themeConfig, db);
// await require('./utils/addonManager').execute(themeConfig, config, app, module.exports.messages);
require("./utils/initPages").init(config, themeConfig, app, db);
},
};
};
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
module.exports.partials = __dirname + "/views/partials";
module.exports.formTypes = require("./utils/formtypes");
module.exports.Feed = require("./utils/feedHandler");
module.exports.cmdHandler = require("./utils/cmdHandler");
module.exports.version = require("./package.json").version;