So my discord bot has a command for doing something based on info from a google sheet. Now the problem is its reading an older version of the sheet rather than reading the live version. Code:
await doc.useServiceAccountAuth({
// env var values are copied from service account credentials generated by google
// see "Authentication" section in docs for more info
client_email: process.env.CLIENT_EMAIL,
private_key: process.env.PRIVATE_KEY.replace(/\\n/g, "\n"),
});
await doc.loadInfo();
const clanappsheet = doc.sheetsByIndex[1];
await clanappsheet.loadCells(`A1:Q${clanappsheet.rowCount}`);
const id = interaction.options.getString('id');
let row1 = 1;
let memberid = clanappsheet.getCell(row1, 11);
let member = memberid.formattedValue;
let memberclanassignment = clanappsheet.getCell(row1, 12);
while (memberid != null && member != id) {
row1++;
memberid = clanappsheet.getCell(row1, 11);
member = memberid.formattedValue;
}
memberclanassignment = clanappsheet.getCell(row1, 12);
I want it to always read the live version of the sheet.