This repository has been archived by the owner on Nov 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
70 lines (60 loc) · 1.85 KB
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const inquirer = require('inquirer');
const Enmap = require('enmap');
const fs = require('fs');
let baseConfig = fs.readFileSync('./config_base.txt', 'utf8');
const defaultSettings = {
'prefix': '!',
'modLogChannel': 'mod-log',
'modRole': 'Moderator',
'adminRole': 'Administrator',
'systemNotice': 'true',
'welcomeChannel': 'welcome',
// eslint-disable-next-line max-len
'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 () => {
console.log('Setting Up GuideBot Configuration...');
await settings.defer;
if (!settings.has('default')) {
prompts = prompts.slice(1);
// eslint-disable-next-line max-len
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();
}());