Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function inventory(userID) {
- const getInfo = new Promise ((resolve,error) => {
- var data;
- function newInventory() {
- var arr = sample;
- var toPush = { 'userid': userID, 'inventory': [] }
- var toPush2 = { 'itemid': '420', 'name': 'weed', 'quantity': '2' }
- toPush.inventory.push(toPush2)
- arr.inventories.push(toPush)
- fs.writeFile ("./info/sample.json", JSON.stringify(arr, null, 2), function(err) {
- if (err) throw err;
- });
- data = toPush; return resolve(data);
- }
- function oldInventory() {
- var i =0;
- var total = sample.users.length;
- var ids = [];
- for(; i < total; i++) {
- ids.push( sample.users[ i ].id );
- }
- var found = ids.find(function(element) {
- return element == userID;
- });
- if (found != userID) { addUser(); }
- else if (found == userid) {
- //get tha inventory of this guy by id
- });
- data = vals; returnData();
- }
- }
- function runChain() {
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement