Improving config handling & startup logic

This commit is contained in:
Logan Cusano
2023-05-06 16:40:15 -04:00
parent 6682d97156
commit 7871b07113
2 changed files with 18 additions and 8 deletions

View File

@@ -20,10 +20,20 @@ class Options {
* @param updatedId The updated ID assigned to the bot
*/
exports.updateId = (updatedId) => {
const options = new Options("id", updatedId);
this.updateConfig('id', updatedId);
}
updateConfigFile(options, (updatedFiles) => {
/**
*
* @param {string} key The config file key to update with the value
* @param {string} value The value to update the key with
*/
exports.updateConfig = function updateConfig(key, value) {
const options = new Options(key, value);
this.updateConfigFile(options, (updatedFiles) => {
// Do Something
log.DEBUG("Updated config file: ", updatedFiles);
})
}
@@ -33,7 +43,7 @@ exports.updateId = (updatedId) => {
* @param options An instance of the Objects class specified to the key being updated
* @param callback Callback when the files have been modified
*/
function updateConfigFile(options, callback){
exports.updateConfigFile = function updateConfigFile(options, callback){
replace(options, (error, changedFiles) => {
if (error) return console.error('Error occurred:', error);
log.DEBUG('Modified files:', changedFiles);