const { writeFileSync, readFileSync } = require('fs');
let json = JSON.parse(readFileSync('./json.json', 'utf-8'));
client.on('message', (message) => {
if (message.content.startsWith(`${prefix}test`)) {
if (json[message.guild.id]?.slot >= 17)
return message.channel.send(`**Lobby 1 IS FULL!, use 1checkin2`);
let s =
message.member.roles.cache.find((r) => r.name === 'Tier1') ||
message.member.roles.cache.find((r) => r.name === 'Tier2');
let msg = '933343245725999134';
let channel = message.guild.channels.cache.get('932431084132646942');
channel.messages.fetch(msg).then((msg) => {
let embed = msg.embeds[0];
var arg = message.content.split(' ').slice(1).join(' '); //
if (!arg) return message.reply('mention first');
if (!json[message.guild.id]) {
json[message.guild.id] = { slot: 1 };
}
embed.addField(
`> `SLOT ${json[message.guild.id].slot}:``,
`${arg}` + `${s}`,
);
json[message.guild.id].slot++;
writeFileSync('./json.json', JSON.stringify(json, null, 2));
msg.edit(embed);
});
}
});
I need to sort them:
so Tier 1 be on top
and Tier 2 be in the bottom
and SLOT number changes with it
how it should look:
I tried using embed.fields.sort
but I couldn’t do it