0
I wanted a way to organize this Json file:
{
"ajuda": {
"name":"Ajuda",
"category": "Sistema",
"desc":"Mostra todos os comandos disponiveis.",
"usage":"ajuda [grupo ou comando]"
},
"ping": {
"name":"Ping",
"category": "Sistema",
"desc":"Usado para saber a latencia do bot.",
"usage":"ping"
},
"status": {
"name":"Status",
"category": "Sistema",
"desc":"Mostra algumas estatística úteis do bot.",
"usage":"status"
},
"convidar": {
"name":"Convidar",
"category": "Miscelânea",
"desc":"Usado para mostrar o meu link de convite.",
"usage":"convidar"
},
"kick": {
"name":"Kick",
"category": "Administração",
"desc":"Usado para expulsar a pessoa mencionada.",
"usage":"kick <@user>"
}
}
In alphabetical order by category. And fit it into this code here:
let currentCategory = "";
let output = `= Lista de Comandos =\n\n[Use ${config.prefix}ajuda <comandos> para detalhes]\n`;
for (var cmd in commands) {
const cat = commands[cmd].category;
if (currentCategory !== cat) {
output += `\u200b\n== ${cat} ==\n`;
currentCategory = cat;
}
output += `${config.prefix}${commands[cmd].name} :: ${commands[cmd].desc}\n`
}
message.channel.send(output, {code: "asciidoc", split: { char: "\u200b" }});
But I’m not getting... I’ve tried 300 ways I found on the internet but nothing.
Sort alphabetically but by category. So I want him to put all of the administration category first, then all of the miscellaneous category and then all of the system category.
– Henrique