Implement Discord CnC Server into Emmelia

This commit is contained in:
Logan Cusano
2023-02-24 21:27:55 -05:00
parent 0ee5c4293f
commit 24b16d87ea
19 changed files with 926 additions and 135 deletions

19
utilities/utils.js Normal file
View File

@@ -0,0 +1,19 @@
// Convert a JSON object to a buffer for the DB
exports.JsonToBuffer = (jsonObject) => {
return Buffer.from(JSON.stringify(jsonObject))
}
// Convert a buffer from the DB to JSON object
exports.BufferToJson = (buffer) => {
return JSON.parse(buffer.toString());
}
/** Find a key in an object by its value
*
* @param {*} object The object to search
* @param {*} value The value to search the arrays in the object for
* @returns The key of the object that contains the value
*/
exports.getKeyByArrayValue = (object, value) => {
return Object.keys(object).find(key => object[key].includes(value));
}