I’m trying to access data from a orders.json file it should list all “orders” however it says “undefined” when i try to do that as shown in the pic below
it also does the same thing when there aren’t any “orders” in the json file
the list command’s code:
const fsn = require("fs-nextra");
const Discord = require('discord.js');
module.exports = {
name: 'list',
description: 'List of all orders',
aliases: ['allorders'],
execute(message) {
fsn.readJSON("./orders.json").then((orderDB) => {
let orderString;
for(let x in orderDB) {
orderString = orderString + "`" + x + "`: " + orderDB[x].status + "\n";
// add newline character at the end to display each "order" on a separate line
}
const exampleEmbed = new Discord.MessageEmbed()
.setTitle('Here\'s a list of the current orders and their status.')
.setDescription(orderString)
.setTimestamp()
.setFooter(message.member.user.tag, message.author.avatarURL());
message.channel.send(exampleEmbed);
});
}
}
data in the json file are stored like this:
{
"tip": {
"orderID": "tip",
"userID": "734532125021307001",
"guildID": "745409671430668389",
"guild": "Cybers Taco Stand Server",
"channelID": "746423099871985755",
"order": "a",
"customer": "Aro#1221",
"status": "Unclaimed",
"ticketChannelMessageID": "not set"
},
}