Updated callbacks to all return
This commit is contained in:
@@ -20,7 +20,7 @@ async function getPresetsOfOnlineNodes(callback) {
|
||||
systems[onlineNode.id] = utils.BufferToJson(onlineNode.nearbySystems);
|
||||
});
|
||||
|
||||
callback(systems);
|
||||
return callback(systems);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ async function requestNodeListenToPreset(preset, nodeId, callback) {
|
||||
"channelID": discordConfig.channelID,
|
||||
"presetName": preset
|
||||
}), (responseObject) => {
|
||||
callback(responseObject)
|
||||
return callback(responseObject)
|
||||
});
|
||||
})
|
||||
}
|
||||
@@ -46,7 +46,7 @@ async function getNodeBotStatus(nodeId, callback) {
|
||||
else {
|
||||
// Bot is free
|
||||
}
|
||||
callback(responseObject);
|
||||
return callback(responseObject);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -58,13 +58,13 @@ async function requestNodeLeaveServer(nodeId, callback) {
|
||||
mysqlHandler.getNodeInfoFromId(nodeId, (nodeObject) =>{
|
||||
reqOptions = new requests.requestOptions("/bot/leave", "POST", nodeObject.ip, nodeObject.port);
|
||||
requests.sendHttpRequest(reqOptions, JSON.stringify({}), (responseObject) => {
|
||||
callback(responseObject);
|
||||
return callback(responseObject);
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Bot is free
|
||||
callback(false);
|
||||
return callback(false);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ exports.sendHttpRequest = function sendHttpRequest(requestOptions, data, callbac
|
||||
}
|
||||
|
||||
log.DEBUG("Response Object: ", responseObject);
|
||||
callback(responseObject);
|
||||
return callback(responseObject);
|
||||
})
|
||||
}).on('error', err => {
|
||||
log.ERROR('Error: ', err.message)
|
||||
@@ -58,7 +58,7 @@ exports.sendHttpRequest = function sendHttpRequest(requestOptions, data, callbac
|
||||
|
||||
if (requestOptions.timeout) {
|
||||
req.setTimeout(requestOptions.timeout, () => {
|
||||
callback(false);
|
||||
return callback(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ connection.connect()
|
||||
exports.getAllNodes = (callback) => {
|
||||
const sqlQuery = `SELECT * FROM ${nodesTable}`
|
||||
runSQL(sqlQuery, (rows) => {
|
||||
callback(rows);
|
||||
return callback(rows);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ exports.getAllNodes = (callback) => {
|
||||
exports.getOnlineNodes = (callback) => {
|
||||
const sqlQuery = `SELECT * FROM ${nodesTable} WHERE online = 1;`
|
||||
runSQL(sqlQuery, (rows) => {
|
||||
callback(rows);
|
||||
return callback(rows);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ exports.getNodeInfoFromId = (nodeId, callback) => {
|
||||
runSQL(sqlQuery, (rows) => {
|
||||
// Call back the first (and theoretically only) row
|
||||
// Specify 0 so downstream functions don't have to worry about it
|
||||
callback(rows[0]);
|
||||
return callback(rows[0]);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ exports.addNewNode = (nodeObject, callback) => {
|
||||
const sqlQuery = `INSERT INTO ${nodesTable} (name, ip, port, location, nearbySystems, online) VALUES ('${name}', '${ip}', ${port}, '${location}', '${nearbySystems}', ${online})`;
|
||||
|
||||
runSQL(sqlQuery, (rows) => {
|
||||
callback(rows);
|
||||
return callback(rows);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ exports.updateNodeInfo = (nodeObject, callback) => {
|
||||
sqlQuery = `${sqlQuery} WHERE id = ${nodeObject.id};`
|
||||
|
||||
runSQL(sqlQuery, (rows) => {
|
||||
if (rows.affectedRows === 1) callback(true);
|
||||
else callback(rows);
|
||||
if (rows.affectedRows === 1) return callback(true);
|
||||
else return callback(rows);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user