I've got an array of objects, these objects have an identifiers
array with strings. One of these strings contains a Discord ID. The problem is its position is changing all the time, so I can't use the 4th identifier for example.
I only need the discord property.
I tried many things. I think it should be something like only "discord" property, but I have no idea how to solve that and code that up. Click on image to see more. There's json file there. It's all about ${players[i].identifiers[4]
const updateMessage = function() {
getVars().then((vars) => {
getPlayers().then((players) => {
if (players.length !== LAST_COUNT) log(LOG_LEVELS.INFO,`${players.length} graczy`);
let queue = vars['Queue'];
let embed = UpdateEmbed()
.addField('Status serwera','<:tak:847199217063297056> Online',true)
.addField('W kolejce',queue === 'Enabled' || queue === undefined ? '0' : queue.split(':')[1].trim(),true)
.addField('Graczy online',`${players.length}/${MAX_PLAYERS}
u200b
`,true);
// .addField('u200b','u200b
u200b
',true);
if (players.length > 0) {
// method D
const fieldCount = 3;
const fields = new Array(fieldCount);
fields.fill('');
// for (var i=0;i<players.length;i++) {
// fields[i%4 >= 2 ? 1 : 0] += `${players[i].name}${i % 2 === 0 ? 'u200e' : '
u200f'}`;
// }
fields[0] = `**Mieszkańcy na wyspie:**
`;
for (var i=0;i<players.length;i++) {
fields[(i+1)%fieldCount] += `${players[i].name} [${players[i].id}], ${players[i].identifiers[4]}`;
}
for (var i=0;i<fields.length;i++) {
let field = fields[i];
if (field.length > 0) embed.addField('u200b',`
${fields[i]}`, true);
}
}
sendOrUpdate(embed);
LAST_COUNT = players.length;
}).catch(offline);
}).catch(offline);
TICK_N++;
if (TICK_N >= TICK_MAX) {
TICK_N = 0;
}
for (var i=0;i<loop_callbacks.length;i++) {
let callback = loop_callbacks.pop(0);
callback();
}
};
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…