2019-11-26 21:22:24 +00:00
|
|
|
const inquirer = require("inquirer");
|
|
|
|
const Enmap = require("enmap");
|
|
|
|
const fs = require("fs");
|
|
|
|
|
|
|
|
let baseConfig = fs.readFileSync("./config_base.txt", "utf8");
|
|
|
|
|
|
|
|
const defaultSettings = {
|
2019-12-24 01:44:12 +00:00
|
|
|
"prefix": "b&",
|
2019-12-22 16:18:30 +00:00
|
|
|
"modLogChannel": "logs",
|
|
|
|
"modRole": "Moderator",
|
|
|
|
"adminRole": "Administrator",
|
2019-11-26 21:22:24 +00:00
|
|
|
"systemNotice": "true",
|
|
|
|
"welcomeChannel": "welcome",
|
|
|
|
"welcomeMessage": "Say hello to {{user}}, everyone! We all need a warm welcome sometimes :D",
|
|
|
|
"welcomeEnabled": "false"
|
|
|
|
};
|
|
|
|
|
|
|
|
const settings = new Enmap({
|
|
|
|
name: "settings",
|
|
|
|
cloneLevel: 'deep',
|
|
|
|
ensureProps: true
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let prompts = [
|
|
|
|
{
|
|
|
|
type: "list",
|
|
|
|
name: "resetDefaults",
|
|
|
|
message: "Do you want to reset default settings?",
|
|
|
|
choices: ["Yes", "No"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "input",
|
|
|
|
name: "token",
|
|
|
|
message: "Please enter the bot token from the application page."
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "input",
|
|
|
|
name: "ownerID",
|
|
|
|
message: "Please enter the bot owner's User ID"
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
(async function () {
|
|
|
|
console.log("Setting Up Cardboard Bot Configuration...");
|
|
|
|
await settings.defer;
|
|
|
|
if (!settings.has("default")) {
|
|
|
|
prompts = prompts.slice(1);
|
|
|
|
console.log("First Start! Inserting default guild settings in the database...");
|
|
|
|
await settings.set("default", defaultSettings);
|
|
|
|
}
|
|
|
|
|
|
|
|
const answers = await inquirer.prompt(prompts);
|
|
|
|
|
|
|
|
if (answers.resetDefaults && answers.resetDefaults === "Yes") {
|
|
|
|
console.log("Resetting default guild settings...");
|
|
|
|
await settings.set("default", defaultSettings);
|
|
|
|
}
|
|
|
|
|
|
|
|
baseConfig = baseConfig
|
|
|
|
.replace("{{ownerID}}", answers.ownerID)
|
|
|
|
.replace("{{token}}", `"${answers.token}"`);
|
|
|
|
|
|
|
|
fs.writeFileSync("./config.js", baseConfig);
|
|
|
|
console.log("REMEMBER TO NEVER SHARE YOUR TOKEN WITH ANYONE!");
|
|
|
|
console.log("Configuration has been written, enjoy!");
|
|
|
|
await settings.close();
|
|
|
|
}());
|